Word stores macros in templates, just as it does styles and AutoText entries. When you create a new macro, it is stored by default in the Normal template and is available "globally" — that is, you can always run or edit the macro, even if the active document is based on a different template. When you store a macro in a template other than the Normal template, you can run or edit it only when the template itself or a document based on the template is the active document.
Whether or not a macro stored in a template other than Normal is available depends on which document is active. For example, if you choose the Macro command when a document attached to a template other than Normal is active, any macros stored in that template, as well macros stored in the Normal template, are available in the list of macros. But if you switch to a document attached to the Normal template and choose the Macro command again, the macros stored in the other template are not listed.
The same holds true for new macros that you create. To store a new macro in a given template, either the template itself or a document attached to the template must be active when you create the macro:
Neither the Normal template nor a document based on the Normal template needs to be active to store new macros globally. You can store new macros in the Normal template even if no documents attached to the Normal template are open.
Note that you choose which template to store a macro in when you create it, rather than when you first save it. Once you've stored a macro in a particular template, you can use the Organizer dialog box to move or copy it to another template. For more information, see "Macro Housekeeping" later in this chapter.
When you open a macro, notice that the title of the macro-editing window includes either the name of the template in which the macro is stored or "Global" if the macro is stored in the Normal template.
Since macros stored in the Normal template are always available and macros stored in other templates are less widely available, you might wonder about the advantages of storing macros in other templates.
One advantage is that macros designed to work with a particular type of document can be stored in the template used to produce that document. Another reason to store macros in different templates is that the Normal template can get crowded. The more macro instructions you store in Normal, the longer it takes to save the template. You won't notice a difference if you have ten or twenty macros stored in Normal, but as you add macros, Normal will gradually take longer to save.
Together, macros and templates can be used to create a Word "application" — a highly customized version of Word designed to accomplish a particular task or set of tasks. For example, a group of macros and templates could be designed to automate the creation of forms and other documents a company uses. Because the macros used in the application are stored within one or more custom templates, the application is relatively simple to distribute; it's just a matter of copying the templates. If the application's macros were stored in the Normal template, it would be much more complicated to install the application on another machine, which already has its own Normal template.
Sometimes it's useful to make a macro or set of macros available temporarily. For example, you may create a set of macros for a task you perform only occasionally. Rather than storing them in the Normal template, you can store them in another template and load that template as a global template when you want to run them.
You use the Templates command (File menu) to load templates as global templates. You can also store a template in the Startup folder (specified on the File Locations tab in the Options dialog box (Tools menu)) to load it automatically as a global template each time you start Word. When a template is loaded globally, its macros become available in the same way macros stored in the Normal template are available. A document based on a loaded global template doesn't need to be active for you to run the macros stored there.
One important difference between loaded global templates and the Normal template, however, is that you cannot edit macros or add new ones to a global template. In effect, a global template is available on a read-only basis.
In the case of a naming conflict (that is, when you select a macro to run when more than one macro with the same name is stored in the available templates), macros stored in the template attached to the active document have priority over other macros. Next in priority are macros stored in the Normal template. Lowest in priority are the macros stored in other global templates (assuming global templates are loaded); priority among other global templates is determined by the alphabetical order of the template names.
Naming conflicts occur most often with "auto" macros, specially named macros that run automatically (for example, when a document is created or opened). For more information on auto macros, see "Auto Macros" later in this chapter.
Naming conflicts may also arise if you modify Word commands. For more information, see "Modifying a Word Command" later in this chapter.