Excel Vba Print To Pdf And Save Jun 2026

ws.ExportAsFixedFormat Type:=xlTypePDF, _ Filename:=filePath, _ Quality:=xlQualityStandard, _ IncludeDocProperties:=True, _ IgnorePrintAreas:=False, _ OpenAfterPublish:=False

Sometimes you need to print a specific sheet named "Summary" while you are working on a different sheet. excel vba print to pdf and save

'If the workbook hasn't been saved yet (path is empty) If FilePath = "\" & BaseName Then FilePath = Environ("USERPROFILE") & "\Desktop\" & BaseName End If excel vba print to pdf and save

To print to PDF, we need to use the PrintOut method with the ActivePrinterMac property (for Mac) or the PrintFile method (for Windows). However, a more straightforward approach is to use the ExportAsFixedFormat method. excel vba print to pdf and save

'Export ws.ExportAsFixedFormat Type:=xlTypePDF, Filename:=filePath MsgBox "Invoice PDF saved as: " & filePath