excel - VBA - 将文件另存为 PDF 到具有预定义名称的特定位置
问题描述
下面的代码可以正常工作,直到生成文件名。它会选择正确的文件夹位置,但文件名是空白的。
如果我在本地机器上的某个位置选择位置,则会出现文件名。你能告诉我我应该怎么做吗?
Private Sub CBSaveasPDF_Click()
Dim FileAndLocation As Variant
Dim strPathLocation As String
Dim strFilename As String
Dim strPathFile As String
strPathLocation = "http://teams.xxx.intranet/sites/bipm/test/test/test/test/test/"
strFilename = Me.Range("D8") & " -" & Me.Range("D7") & " -" & Me.Range("J7") & " " & Me.Range("B3")
strPathFile = strPathLocation & strFilename
FileAndLocation = Application.GetSaveAsFilename _
(InitialFileName:=strPathLocation & strFilename, _
filefilter:="PDF Files (*.pdf), *.pdf", _
Title:="Select Folder and FileName to save")
If FileAndLocation = "False" Then
MsgBox ("Document not saved")
Exit Sub
End If
Me.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=strFilename, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
解决方案
推荐阅读
- python - 如何通过函数运行日期字符串列表并将每个项目的结果作为一个连接字符串返回?
- assembly - 用简单的英语解释这个汇编语言程序的作用
- javascript - 如何通过选择表单从给定的表单元素中找到特定的类
- php - ajax 数据表没有响应
- html - SVG 投影但在 a:hover
- c# - 如何摆脱报表查看器 C# 中的空格?
- rust - Bindgen 似乎无法在 OSX 上找到 clang
- docker - 保持 Docker 容器存活的正确方法是什么?(uWSGI 相关)
- php - Laravel - 限制雄辩的查询请求(节流?)
- php - MySQL 1064 (42000) 语法错误 - 从网站复制/粘贴推荐代码(更新用户)时(这里也是!)