Template macros are simply macros that are stored in the template itself. This has two advantages over the normal macros on disk. First, the macro automatically goes with the template so that if you want to share your template with another user or copy to another computer, you only have to copy the template file and not other macros. The second advantage is that you can associate a template macro with what is called a trigger. The template macro runs before or after the occurrence of particular events such as opening the file, printing, or closing the file. The use of macro triggers is explained further in the next page.

There are also a couple of disadvantages to template macros. First, the use of too many template macros may make the template file itself very large. Second, templates tend to be more easily corrupted than macros so that retrieving template macros may be problematic in the worst case scenario. Finally, template macros are not easily shared when working with other templates. Though you can copy template objects, including template macros, from template to template, this is a bit cumbersome if you try to store all your macros as template macros. Consider all these factors when deciding whether to use a template macro or a normal macro on disk.

There are three ways to create a template macro. The first is to record the template macro inside the template itself. The second is to copy it from a macro on disk and the third is to copy it from another template macro.

Recording a Template Macro

Recording a template macro is straight forward:

   While creating a new template or editing an existing template, click the menu bar item Tools | Template Macros | Record.
   In the Record Template Macro dialog box, give the template macro a name. By default, the macro will be stored in the template you are editing (you do have the option to store it in your default template).
   Click the Record button on the dialog and record whatever actions you desire.
   To stop recording, you will have to click the Stop button on the property bar (the button on the left with a black square).

Close and save the template. To play the template macro, you will first have to create a new document based upon that template. Then click on the menu bar item Tools | Template macros | Play and select the template macro from the list displayed. You can also have the macro run automatically when certain predefined events or triggers occur. That concept is discussed in a separate page.

Copying a Macro from Disk or Another Template

You can copy a macro from a disk or from another template and store it your custom templates. First, here's how to copy a macro from disk. With your template open for editing:

   Click the Copy/Remove Object button on the property bar.
   In the Object type drop down box, select Macros on disk. Use the small browse button in the edit box to select the macro you wish to select from disk.
   Click the Copy button. The macro will now appear in the list box of stored macros.
   Click the Close button. The macro now is stored in the template.

Copying a macro from another template is essentially the same.

   Click the Copy/Remove Object button on the property bar.
   In the Template to copy from drop down box, select the appropriate template.
   In the Object type drop down box, select Macros.
   Select which macro to copy and lick the Copy button. The Copy all button will copy all the template macros to the current template. The macro(s) will now appear in the list box of stored macros.
   Click the Close button. The macro now is stored in the template.

You probably noticed something exciting while you were copying these macros. You can copy a whole lot more than just macros from another template. You can copy menu bars, toolbars, quickwords, and more. The process of copying these is the same as copying template macros. Now you can create custom templates which contain customized macros, toolbars, etc. and distribute them to other users.

You can create buttons on your toolbar to play the template macro, assign them to keystrokes, or create menu items to play them. Check out your WordPerfect help files or manual for details on how to do this. You can also associate your macros with certain triggers which cause the macros to run on certain predefined events. Click the tour button on the left or follow the link below for details on how to do this.

Previous Page | Next Page