Mac Excel VBA 代码打印文件而不是导出 PDF

问题描述 投票:0回答:0

我正在尝试将 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
excel vba excel-formula excel-2010 excel-2007
© www.soinside.com 2019 - 2024. All rights reserved.