Terry's TMG Tips

Recording Word Macros to Format TMG Reports

This page updated 29 Feb 2010

Version note: Applies to TMG 8 & 9

This article describes how to record a macro in Word 2007, including step-by-step instructions for recording a macro I have designed to reformat Journal reports created in TMG. Readers can use these instructions to record their own macros, using, if they find them useful, the techniques I have used as a guide in creating your own sequence of steps.

Topics Included in this Article
Recording a Macro
How to record a macro in Word 2007
Terry's Word Macro
An overview of the edits done by Terry's Word macro
Recording Terry's Macro
A step-by-step guide to recording Terry's Word macro

Those who would prefer to download and install the macro I have created should see my article on Downloading Terry's Word Macro. Readers using a version of older than Word 2007 please see my article for Word97.

Recording a Macro in Word 2007

The following steps describe how to record a macro in Microsoft Word 2007; minor adjustments may be required for later versions. If you use an earlier version of Word see my article for recording macros in Word97.

  1. With a copy of the document you want to edit open, go through the entire series of operations you want to record, repeating until you have a sequence that correctly does what you have in mind. If you make a mistake, load a fresh copy of the document and repeat until you have the steps correctly in mind.
You can use the mouse to select ribbon commands and options within dialog boxes. But you cannot use the mouse to navigate in the body of the document, for example to select text or reposition the courser – you must only use keyboard commands for that.
  1. Once you have perfected your sequence, start again with a fresh unedited copy of your file, and you are ready to record.

  2. On the View ribbon, in the Macros section at the far right, click the Macros button with the small down arrow on it, and select Record Macro to open the Record Macro dialog.
Start Macro
  1. In the Record Macro dialog, give the macro a name you will recognize (no spaces allowed – maybe something like FormatTMGReports).
Record Macro screen
  1. I suggest assigning the Macro to a button on the Quick Access toolbar to make it handy to use. To do that:
Word Options Screen
Word Options screen
  1. You could instead assign a keyboard shortcut to the macro. To do that:
  2. Click OK, and recording starts. The cursor changes to show that recording is underway.

  3. Step through all the operations you want to include in your macro. When you are finished, click same button in the Macros section of the View ribbon, and choose Stop Macro.
Stop Recording
When you exit Word you may be asked whether you want to save changes to the Global Template. Click the Yes button to save your macro (it is saved as part of your "Normal" template.)

To test the macro, open a fresh unedited copy of the file and click the toolbar button you added in step 5 above, or use the keystroke you set in Step 6. If you did neither click the Macros button shown above, choose "View Macro," and in the Macros dialog box, select your macro, and click Run.

If you made an error in recording, start over with a fresh copy of your document, using the same name for the macro.

Terry's Word Macro

The macro I have created makes the following changes to TMG's Journal reports:

  1. Change top and bottom margins, and spacing of footer from bottom of page.

  2. Underline the "Generation xxxx" headings, and remove a blank line after each heading.

  3. Remove blank lines TMG inserts immediately before and after the report title.

  4. Create a footer with a graphic line above, my name left, page number centered, date in the desired format right, and a smaller font.
Rather than creating the footer in TMG and editing it, I found it easier turn off footers in the Report Definition screen, and create it from scratch in the macro. If you plan to follow the steps described below you should make that change in your report definition before you start.
  1. Reformat endnotes into two columns and adjust the spacing between notes.

Steps to Record Terry's Macro

The steps below are designed to make the formatting changes described above. The specific steps that you would record depend on exactly what you want to accomplish. The steps outlined below illustrate a number of useful techniques, and should be helpful as a guide in creating your own sequence of steps. You could of course add or delete steps, or modify the specific settings, to suit your preferences, or adapt the techniques to do entirely different tasks.

These instructions use the commands in Word 2007; if you are using an older version of Word please see my article for Word 97.
 

Before starting to record the macro, you need to open in Word a report of the type the macro will apply to. Then start macro recording as describe above and complete all the steps you want the macro to produce.

A. Adjust Margins and Footer Spacing

The steps in this section set the margins to values not available within TMG.

B. Underline Generation Labels

The steps in this section add an underline to each of the "Generation xxx" section labels.

C. Delete the Extra Spacing After the Headings

These steps remove a single blank line in several places, including after the main title and the generation labels.

D. Remove the Blank Lines Before the Report Title

This step removes the blank line above the report title.

E. Add the Footer

I wanted a footer format not available with the options in TMG. Rather than creating the footer in TMG and editing it, I turn off footers in the Report Definition screen, and create it from scratch in the macro.

First, we add a line above the footer (a "border") and set up centered and right tabs for the text that is to be in the footer.

Next we enter the actual text of the footer. Start with the cursor in the footer area at the bottom of the dialog box.

Finally, we set the font size for the footer text.

F. Format the Endnotes

First we edit the Endnote Separators to remove the separator lines, which do not work well in double column mode, and adjust the heights of the now-blank lines to better align the left and right columns on the first Endnotes page.

This is the end of the steps that remove the separator lines. Now we move to setting up the endnotes themselves, arranging them in two columns, and adjusting the spacing between notes.

That is the end of the macro recording. Stop and save the macro, then test it to be sure it works as intended.

ReigelRidge Home Terry's Tips Home Contact Terry

 

The Second Edition of my sell-out book, A Primer for The Master Genealogist, is now available.

Details are can be seen here.

 

Copyright 2000- by Terry Reigel