Microsoft Word: Adding Macros the Normal Template
The automation of repetitive task is a good use for macros.
A macro is a way to save time on tasks you do regularly by grouping together the series of commands and instructions normally required to do the task into a single command. This allows you to execute that task quickly and easily. And frees you from having to remember all the steps to follow every time you need to do it!
In Microsoft Word, special macro enabled documents and templates store macros.
The format extensions of these Word file types are "docm" and "dotm."
Macros stored in a "docm" type of file are only available to that specific document.
Macros stored in template "dotm" files can be available to all documents that use the template.
Word's Normal template is global, macros stored in it are available to all documents.
How to add a Macro
To add macro from scratch, meaning writing it yourself, or adding one that you have copied from a trusted source do the following:
STEP 1: Press the keyboard sequence of Alt + F8. This opens the macro dialog. If you already have macros installed, they appear on the dialog in alphabetical order.
STEP 2: In the "Macros in:" box use the down arrow control to change the value to "Normal.dotm (global template)"
STEP 3: In the "Macro name:" box enter a unique name for your new macro.
No duplicate names allowed.
The first letter of the name must be an alphabetic character.
You cannot use spaces, periods, or any special character other than an underscore character in the name.
STEP 4: When you are ready, click the "Create" button and a placeholder appears for your new macro subroutine in the Visual Basic Editor (VBE) of Microsoft Word.
STEP 5: Paste or type the VBA code script for your new macro between the "Sub" and "End Sub" statements of the VBA routine.
The term "Sub" is short for Subroutine. Green text are comments, they do not execute and are only for documentation purposes.
All comment lines start with a single quote mark.
You can add or remove comments as needed.
NOTE: If you paste an existing VBA subroutine and have copied both the Sub and End Sub statements:
when you paste the subroutine into the Visual Basic Editor panel, you will need to remove the duplicate Sub and End Sub statement lines.
In you are interested writing your own sub procedures, follow the instructions provided by Microsoft for more information on Writing a Sub procedure
Macros you can copy and use
In our article Microsoft Word: One Space or Two After Each Sentence? we include a macro you can use if fixing sentence spacing is a common scenario. This macro will save you time because after adding it all you will need to do is press a custom button or custom keystroke sequence to run the macro to get the job done.
In a subsequent article I will provide a subroutine to help you manage spacing on a page.