Forum Discussion

Luke5068's avatar
Luke5068
Copper Contributor
Feb 09, 2022

Excel for Mac (VBA) prints file instead of saving it as PDF. Windows works fine.

Hi, I have a problem saving PDF files via macro in Excel for Mac. The code below works fine on Windows. However, when it is run on Mac, the file is not saved but the default printer prints the file. Can anyone help me here? Thanks a lot in advance!

 

Sub TimesheetSpeichern()
Dim xl_Master_Timesheet As Object
Dim ws_Rechnungen As Object
Dim ws_Vorlagen As Object
Dim invoiceRng As Range
Dim pdfile As String
Dim strfile As String


Set invoiceRng = Range(ActiveSheet.PageSetup.PrintArea)
   Set xl_Master_Timesheet = ThisWorkbook
    Set ws_Rechnungen = xl_Master_Timesheet.Sheets("Rechnungen")
    Set ws_Vorlagen = xl_Master_Timesheet.Sheets("Vorlagen")
    pfad_Zielpfad_1 = ws_Vorlagen.Range("Zielpfad_1").Value
    

strfile = "invoice" & "_" & Format(Now(), "yyyymmdd_hhmmss") & ".pdf"
pdfile = pfad_Zielpfad_1 & strfile

invoiceRng.ExportAsFixedFormat Type:=xlTypePDF, _
FileName:=pdfile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False


End Sub••••ˇˇˇˇd

 

No RepliesBe the first to reply

Resources