Microsoft Word 2007 comes with a Visual Basic for Applications (VBA) code editor in which you can create controls that allow you to perform functions that ordinarily may not be available. With Word 2007, you can use the VBA code editor to save your Word documents in PDF form, which can be handy if you want to distribute your reports and documents in a format other than the ".docx" file format that Word uses. Before you can use a VBA code to save documents in PDF form, however, you must enable support in Microsoft Word for the PDF format through a free Microsoft add-in.
Open Microsoft Word 2007. Click the blue help icon in the top, right corner of the program. Type "pdf and xps file formats" in the Word Help search box and press "Enter." Click the "Print, share and protect files in the PDF and XPS file formats" search result.
Click "Install and use the Save as PDF or XPS add-in from Microsoft" in the "What do you want to do" section. Click the blue-formatted Internet link that reads "Microsoft Save as PDF or XPS Add-in for 2007 Microsoft Office programs" to be taken to the add-in download page. Close the Microsoft Word program.
Click the "Download" button on the add-in page. Save the file to your computer. Double-click the file to open it. Click the check-box to accept the Microsoft Software License Terms. Click "Continue" and wait for the installation to complete.
Open a Microsoft Word document that you want to convert to PDF. Click the Office button and select "Word Options." Click the "Show Developer tab in the Ribbon" check box to enable it. Click "OK."
Click the "Developer" tab in the Ribbon. Click "Macros" in the "Code" group. Type "SaveToPDF" or another name of your choice in the "Macro name" box. Click the "Create" button.
Type the following VBA code lines, or copy and paste them, in the "New Macros (Code)" window in the line directly above the "End Sub" line:
ActiveDocument.ExportAsFixedFormat OutputFileName:= _
ActiveDocument.Path & "\" & ActiveDocument.Name & ".pdf", ExportFormat:= _
wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _
wdExportOptimizeForPrint, Range:=wdExportAllDocument, _
Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
Click the "File" menu and click "Close and Return to Microsoft Word."
Click "Macros" in the "Code" group in the "Developer" tab. Click the name of your macro to highlight it if it is not already selected. Click "Run" to run the VBA code and automatically save the Word document as a PDF file. Navigate to the folder location on your computer in which your Word document is saved to find the PDF version of the file.
Open any other Word documents that you want to save as a PDF. Click the "Developer" tab, click "Macros," select the name of the macro you created and click "Run."
Things you need
- Microsoft save as PDF or XPS add-in