我正在尝试将 PDF 文件导出到特定文件夹(如果不存在则创建一个新文件夹)。当我运行宏时,它会打印一个文件而不是保存 PDF。我正在使用 macOS Ventura 13.0.1 和 Office LTSC Standard for Mac 2021。有人可以帮助我吗?谢谢。
这是我正在使用 rn 的代码。
Sub SaveAsPdf()
Dim number As Long
Dim name As String
Dim strFolder As String
Dim strPath As String
Dim fname As String
strPath = ThisWorkbook.path & Application.PathSeparator
fname = number & " - " & name & ".pdf"
'Determine File Name From Cell Contents
strFolder = strPath & "PDF/"
'Create Folder
On Error Resume Next
MkDir strFolder
On Error GoTo 0
'using Application.PathSeparator to identfy the "/" or "\"
ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
FileName:="/" & strPath & strFolder & fname & ".pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=False, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
End Sub