Vba export worksheet as pdf in Excel
To do it in Excel, here is the answer:
- Option Explicit
- Sub ExportAsPDF()
- Dim sOutputFolderPath As String, sFileName As String
- ''
- sOutputFolderPath = "C:\Users\Guest\Documents\TestFolder\"
- sFileName = sOutputFolderPath & "PDF_Export_Example.pdf"
- ''
- Export ActiveSheet as PDF.
- ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=sFileName, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
- ''
- End Sub
Description:
a) Line 9 - ActiveSheet is exported as a PDF in the Output folder specified with assigned filename. If required, print settings need to be applied prior to exporing PDF.