Vba export worksheet as pdf in Excel

To do it in Excel, here is the answer:

  1. Option Explicit
  2. Sub ExportAsPDF()
  3. Dim sOutputFolderPath As String, sFileName As String
  4. ''
  5. sOutputFolderPath = "C:\Users\Guest\Documents\TestFolder\"
  6. sFileName = sOutputFolderPath & "PDF_Export_Example.pdf"
  7. ''
  8. Export ActiveSheet as PDF.
  9. ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=sFileName, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
  10. ''
  11. End Sub


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.


You can find similar Excel Questions and Answer hereunder

1) Vba length of an array in Excel

2) How can I set up ListBox using VBA to allow users to select multiple values?

3) How can I copy and rename a WorkSheet using VBA?

4) How can I dynamically add series to an existing chart using VBA?

5) How can I identify all cells with Conditional Formatting in my WorkSheet?

6) How to hide and unhide rows and columns in excel VBA

7) How can I get input from user through a prompt and assign user's input to a cell?

8) How to print a worksheet in Excel VBA

9) The name manager in Excel is very useful to keep an overview and manage all the variable names in Excel. Here how to use the name manager in VBA

10) How to do webscrapping in VBA. Here some basics


Here the previous and next chapter