这在 exportpdf 级别有什么问题? 它正确保存了第一个文件,但之后会出错。 我已经删除了大部分宏,以防万一里面有一些看起来不需要的东西。 如果我只有这个 它按我想要的方式工作,但我不想要迭代器作为文件名 ...
提示:本站收集StackOverFlow近2千万问答,支持中英文搜索,鼠标放在语句上弹窗显示对应的参考中文或英文, 本站还提供 中文繁体 英文版本 中英对照 版本,有任何建议请联系yoyou2525@163.com。
我想现在我尝试了几乎所有方法来使用 Excel vba 保存 pdf 文件。
这是我的实际代码:
Dim pdfFile As String
If excel2016 Then
pdfFile = Application.DefaultFilePath & "/Report_" & year & month & "_" & Replace(name, " ", "_") & ".pdf"
Else
pdfFile = ActiveWorkbook.Path & Application.PathSeparator & "Report_" & year & month & "_" & Replace(name, " ", "_") & ".pdf"
End If
wsOutputOne.ExportAsFixedFormat Type:=xlTypePDF, fileName:=pdfFile
我知道 Excel 2016 正在创建一个“容器”并将文件保存在~/Library/Containers/com.microsoft.Excel/Data/Documents/
但为什么该代码不适用于 Excel 365?
或者使用 Excel 365 的朋友如何保存生成的 pdf 文件?
因为Application.DefaultFilePath
的调用在他的机器上没有返回任何东西......
有人可以帮助我吗?
请尝试以下代码:
Dim pdfFile As String
If excel2016 Then
pdfFile = Application.DefaultFilePath & "/Report_" & year & month & "_" & Replace(name, " ", "_") & ".pdf"
Else
pdfFile = Application.ActiveWorkbook.Path & Application.PathSeparator & "Report_" & year & month & "_" & Replace(name, " ", "_") & ".pdf"
End If
wsOutputOne.ExportAsFixedFormat Type:=xlTypePDF, fileName:=pdfFile
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.