Macros

Macros are fun. Having the right macro – especially one you’ve struggled to write yourself – is like a Get Out of Jail Free card. When the software you depend on doesn’t do what it claims to do, or what you need it to do, then sometimes a good macro will provide a way of escape.

Microsoft’s Visual Basic for Applications (VBA) is a good example.

Are there actions you take dozens and dozens of times each day during the hours you spend working on documents in Microsoft Word? How many mouse clicks and keyboard actions does it take each and every time. Here’s an example…

Tracking Changes

When I make a small edit to a document, I like to have change tracking enabled (with an Author Name unique to this iteration of the document). I type in or paste in the new content. I select the new text and mark it with a comment balloon, but since Word has issues dealing with interwoven comments, I like to disable change tracking before putting in the comment. I then go to the bottom of the document, where I keep a detailed Change History. I make an entry there with the date, a short description of the change (and attribution to its originator), and add a cross-reference link to the place where I edited. (This detailed Change History is an invaluable resource for reviewers.) All of this uses at least 20 mouse or keyboard actions, and that assumes the writer knows the keyboard shortcuts for items such as “Enable/Disable Change Tracking” (Command-Shift-E).

I created two macros to shorten the procedure to about 6 clicks. More could be done (e.g., by capturing the comment text string onto the Clipboard, automatically moving to the end of the document, in the rightmost column on the last row of the Change History table, pasting in the Clipboard text, etc.), but exceptions to this sequence limit how effective such a lengthier macro would be. I assign each macro to an unused key combination. (In the Windows version of Word, I assign each macro to an icon and put on the Quick Toolbar. On a Mac, this is not an option.)

Module1

{You might notice, in the above macro listing, that the bookmarks used to mark each edit, and provide an anchor for cross-references, tend to ‘build up’ over time. Another short macro is used to delete the EDITyyyymmdd_xxx bookmarks when the project moves from one ‘release candidate’ document to the next. Reviewers can go back to the earlier versions to research the origin of changes.}

Checking Symbol Usage

Another reason for Word macros is to get something done which simply cannot be done by editing, and you don’t want to rely on external software to open and parse through the Word file to get it done. Here’s an example…

Long technical documents often have long lists of symbolic names sprinkled through the text. For electrical specifications, these can be voltage limits, timing parameters, and the like. Most of these symbols use subscripts in the name. The challenge comes in three places: (1) making sure all usages of a symbol are spelled identically in the document; (2) making sure that the symbol is defined somewhere and only once; and (3) checking that the same symbol names used in related Word files are spelled and used consistently.

A combination of macros, run from the Developer tab, can be used as a king of “poor man’s compiler” to check the names and definitions. Additional macros can output .csv or text files, which can then be read in to the other Word files (with macros) to check that their symbol spelling is consistent, or used as “error reports” to track down missing or inconsistent symbol usage. All of this works while keeping the authoring and editing within Word – the tool most familiar to technical contributors.