How to Create Dynamic Word Documents

by Tiesha Whatley

A dynamic Word document is a document that has some VBA (Visual Basic for Application) code behind it to complete automated or complex tasks. These tasks can range anywhere from adding rows to tables to exporting information to other Office applications. VBA modules can be used to send out mass email documents or even creating documents based on templates just by clicking a single button. To make your Word documents dynamic, you will need to have understanding and knowledge of Microsoft Word, VBA and macros.

1

Open up or create a Word document. You can start from a document that is already created, from a template or a blank document. It all depends on what you want to do.

2

Open up the VBA Editor. Click on "Tools > Macros > Visual Basic Editor" if you are using Word that is 2003 or earlier. For Word 2007, you may have to make the "Developer" tab visible first. To do this, click on "Office button > Word Options". Click the checkbox next to "Show Developer tab on the ribbon" and then "OK." You should now see the "Developer" tab. Click on it and then "Visual Basic" to open the VBA Editor.

3

Create a new procedure. Double-click on "ThisDocument" in the Project window on the right-side pane. Click on "Insert > Procedure." Type in a name for your new procedure in the "Name" box and choose whether it is a "Sub", "Function" or "Property" procedure. Also choose whether the procedure will be "Public" (can be used throughout the entire document) or "Private" (only used within the selected module).

4

Add the code for the procedure. The code depends on the task you want Word to perform dynamically. Finish adding the code and click the "Run" icon on the toolbar to test it for errors. Once the code comes back without errors, save the procedure and close the VBA Editor.

5

Run your new procedure. Click on "Tools > Macro > Macros" to open the Macros dialog box in Word 97 to 2003. For Word 2007, click on the "Developer" tab and then "Macros." Click on the procedure you just created (it should be listed in the window with any other macros) and click "Run".

Items you will need

About the Author

Tiesha Whatley has been writing for over 10 years. She has been published in "Marie Claire," "Ebony" and "Modern Bride" magazines. She holds a Bachelor of Science in English from the University of Alabama at Birmingham and has been working in the wedding planning industry for over 13 years.

Photo Credits

  • photo_camera Jupiterimages/Photos.com/Getty Images