How to Convert Docx to PDF – VBA Save Word as PDF

How To Save Word Document as PDF?

PDF refers to “Portable Document Format”.

In order to avoid copying or alteration of information by the third party or unauthorized user, We convert the word document to PDF. PDF files cannot be altered.

While sending the important files as a word document, there are chances that it get modified by other user. By converting the Docx to PDF you can avoid the document getting edited by anyone.

Now, here are few easy ways to covert Word to PDF format.

We will see them one by one.

1. Easy Steps to Convert MS Word Docx to PDF

It is the simplest way of converting a word document to PDF.

Converting Docx to PDF - using VBA to save word to PDF
Converting Docx to PDF – using VBA to save word to PDF
  • Open Word file to be converted to PDF.
  • Choose Save As option from file tab (or accessibility tab or using ALT+F+A)
  • Change “save As type into PDF(*PDF)
  • Select “Option” box.
  • Tick these ‘check boxes’ in additional options -> Non-Printing Information section.
    • Create Bookmarks using: Headings
    • Document properties
    • Document structure tags for accessibility
    • Click Continue.
  • Then click “OK”.

Now, Your Word document will be saved as a “PDF” file.

Note: If your create bookmarks with ‘heading’ not checked in, then your document will not have a perfect heading. Proper heading and alignment will be followed along with the page number if you follow the above steps correctly.

This will convert all pages in the docx file to PDF. This option is available only in the higher version of office like 2010, 2013, 2016 etc.,

Now, lets see how to do this a Vba code.

2. VBA Code to Save Word as PDF

This vba code is written to run as Word document. From the word document that needs to be converted to PDF, press Alt + F11, then copy paste the bwlo code.

In case if you would like to automate this process from Excel or Outlook, then an object for word.application has to be created first. Then the use the PDF export function, so that word can be accessed using that object.

Sub ConvertWordDocxToPDF()
    'Code from Officetricks
    'Define variable fields
    Dim sFolderPath As String
    Dim sFileName As String
    Dim sNewFileName As String
    
    'Check if Folder Exists
    sFolderPath = ActiveDocument.Path & "\"
    
    'Set New File Name
    sFileName = ActiveDocument.Name
    sNewFileName = VBA.Mid(sFileName, 1, VBA.InStrRev(sFileName, ".", , vbTextCompare) - 1)
    sNewFileName = sFolderPath & sNewFileName & ".pdf"
    
    'Save File
    ActiveDocument.ExportAsFixedFormat OutputFileName:=sNewFileName, _
        ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _
        wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1, To:=1, _
        Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
        CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
        BitmapMissingFonts:=True, UseISO19005_1:=False
End Sub

Run the code by pressing F5. It will export the current Word document to a PDF file with the new name given in the code.

Related topic: Convert Excel to PDF

We could use this conversion from word to pdf to save the intermediate work we do while editing a word document or while reviewing for any quality.

3. Convert Word File to PDF – Using Adobe

The other method for creating the PDF file of your word document is using Adobe Acrobat Professional. Adobe Acrobat Professional version 10 or above are suitable for converting document created with Microsoft word 2010 in PDF.

If you have already installed this version of Adobe Acrobat, along with plug in for Word, then the acrobat tab will appear in the word document itself. When you open the tab you will find the options under “Acrobat tab”. You will see a Create PDF icon & a Preferences icon in the Create.

3.1 Adobe PDF Group

3.1.1. Settings Tab:

In the “Settings tab” first configure the settings that are needed to convert the word to PDF file. Click preferences to open the, Acrobat PDF Maker dialog.

  • Then, in the Application Settings section of the Settings tab, make sure that below three check boxes are ,checked:
    • Create Bookmarks,
    • Add Links, and
    • Enable Accessibility and Reflow with tagged Adobe PDF.
  • Make sure the Prompt for Adobe PDF file name check box is checked in, leave the other tab(s) unaltered (even you can add password to the document in the same settings tab else you can leave it as it is).

3.1.2. Word Tab:

On the Word tab, make sure the following check boxes are checked:

  • Convert footnote and end note links.
  • Enable advanced tagging.

3.1.3. Bookmarks Tab:

  • Make sure the Convert Word Headings to Bookmarks check box is checked, and make sure all of the heading levels are selected in the element list.
  • Save the Preferences, once you have completed your selections, click the OK button to save your preferences and exit the PDF Maker dialog.

Configuration is completed. Now start Converting Word to PDF.

3.2 Word to PDF Conversion Steps

If you selected the option to prompt for Adobe PDF file name in the preferences,

  1. you will see a dialog titled “Save Adobe PDF File As,” where you can specify a new file name & location.
  2. In that case, update the file name and click save to finish.
  3. While the file is being processed, a status dialog will display briefly, but because the process happens so quickly, it may disappear as quickly as it appeared.
  4. Finally, if you selected the option to View the PDF result in your preferences, the new PDF file displayed.

You can also use online converters to convert the documents. Some of the free online editors are available in online you can use those things to convert.

External Reference: Discussion on saving Word Doc to PDF

Leave a Reply