This page explains how to save a word document to PDF using:
- VBA Code PDF Converter
- Manually Save Word as PDF
Both the methods are simple & straight forward. Lets start with the automation code first.
1.VBA Code to Convert Word to PDF
Word VBA has a direct function to export word document into PDF & XPS format. The function name is ExportAsFixedFormat. Just use this function, pass the output PDF file name along with path.
If required pass the starting & ending page numbers.
Sub saveWordasPDF() 'Define File Path sFilePath = "<D:/foldername/pdffilename.pdf" 'Export as PDF ActiveDocument.ExportAsFixedFormat _ outputfilename:=sFilePath, _ exportformat:=wdExportFormatPDF, _ openafterexport:=True End Sub
After executing the code, go to the output folder path. Verify whether the PDF file is generated.
In case the PDF alignment or text format is not in proper format, then modify the input word document accordingly.
2. Manually Export Word to PDF
This method is also straight forward one. The option is available in the MS Word Menu itself. Follow these steps to export Word to PDF
- Click on File Menu
- Choose ‘SaveAs’ option.
- Select Folder path.
- In ‘Save type as’ drop-down, choose PDF.
- Click Ok
There is anothe alternate option as well. Instead of Saveas, you also use print (Control + P) option. This also has option as ‘Print to PDF’. Both the options work well. Just that in the print option, you can choose starting & ending page numbers.
External Link: Here is another article with code that explains about saving word to PDF.