How to Convert Word to PDF Macro

Written by stephanie ellen
  • Share
  • Tweet
  • Share
  • Email

A macro is a piece of executable Visual Basic for Applications code, or VBA, in Microsoft Word. A macro helps you customise Word to fit your needs and replace repetitive tasks. For example, if you constantly find yourself converting Word documents to PDFs, a macro button can replace several keystrokes with a single macro function. You write the code once and use it whenever you want to turn a Word document into a PDF. VBA is built into Word 2007 and Word 2010.

Skill level:

Other People Are Reading

Things you need

  • Word 2007 or Word 2010

Show MoreHide


  1. 1

    Press "Alt" and "F11" in Word. This opens the Visual Basic Editor, or VBE, where you enter the VBA code.

  2. 2

    Click on "Insert" and then click on "Module" to open a new window.

  3. 3

    Cut and paste the following code into the window:

    Sub WordtoPDF()


    ' WordtoPDF Macro



    ActiveDocument.ExportAsFixedFormat OutputFileName:= _
        "C:\Desktop\Doc1.pdf", ExportFormat:=wdExportFormatPDF, _
         OpenAfterExport:=True, 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

  4. 4

    Modify the output file in the code to show where you would like the PDF to end up. In the above example, the file is sent to the Desktop.

  5. 5

    Press "F5" to run the program.

Tips and warnings

  • Press "alt" and "F11" to toggle between the VBE and the regular Word window. To run the code without entering the VBE, click on the "Developer" tab and then click on "Macros." Click on the macro name---(the macro name of this subroutine is WordtoPDF---and then click on "Run."

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.