How to Convert Word to PDF Macro

Updated February 21, 2017

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.

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

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

Cut and paste the following code into the window:

Sub WordtoPDF()


' WordtoPDF Macro



End Sub

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.

Press "F5" to run the program.


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."

Things You'll Need

  • Word 2007 or Word 2010
Cite this Article A tool to create a citation to reference this article Cite this Article

About the Author

Stephanie Ellen teaches mathematics and statistics at the university and college level. She coauthored a statistics textbook published by Houghton-Mifflin. She has been writing professionally since 2008. Ellen holds a Bachelor of Science in health science from State University New York, a master's degree in math education from Jacksonville University and a Master of Arts in creative writing from National University.