Triggering macros from templates

You can play a macro as you use a template. For example, if you use a template to create letters, you can set a PRE PRINT trigger in the template that runs a spell-check macro. The macro then lets you check the spelling of your letters just before they print.

You can use the following macro triggers.

Trigger
Description
POST CLOSE
Runs in the active window after you close a window.
POST NEW
Runs after you open a window by clicking File WordPerfect Office onestep Triggering macros from templates New.
POST OPEN
Runs after you open a window by clicking File WordPerfect Office onestep Triggering macros from templates Open.
POST PRINT
Runs after you send a print job to the printer.
POST STARTUP
Runs when you start WordPerfect. The macro must be associated with the default template.
POST SWITCH DOC
Runs in the active window after you switch from another window.
POST TABLES
Runs after you create a table structure in a document, but before you enter data in the table.
PRE CLOSE
Runs before you close the active window by clicking File WordPerfect Office onestep Triggering macros from templates Close.
PRE NEW
Runs in the active window before you open another window by clicking File WordPerfect Office onestep Triggering macros from templates New.
PRE OPEN
Runs in the active window before you open another window by clicking File WordPerfect Office onestep Triggering macros from templates Open.
PRE PRINT
Runs after you click File WordPerfect Office onestep Triggering macros from templates Print, but before the print job is generated.
PRE SWITCH DOC
Runs in the active window before you switch to another window.
PRE TABLES
Runs after you insert a table by clicking Insert WordPerfect Office onestep Triggering macros from templates Table, but before the table structure is created in the current window.


Adding the TemplateFill macro command

The TemplateFill() macro command displays a dialog box that lets you enter template data. This dialog box varies depending on the fields required for the current template. If personal information is not specified, this command first prompts you to specify personal information regardless of what data the current template requires. If the current template does not require data other than personal information, and the personal information has been set, this command updates the personal information in the document without displaying the dialog box. If the current document is not based on an automated template, and the personal information has been set, this command does nothing.

Only macros that have been added to the template can be used with triggers. A trigger specifies when a macro plays in a template (for example, before you close a document).

Macros on disk cannot be associated with a trigger. Running the Prompt Builder associates the POST NEW trigger with <dofiller>, the feature that runs the Prompts dialog box. If the POST NEW trigger is associated with a template macro, use the TemplateFill() macro command in that template macro to activate the DoFiller feature.

If you want DoFiller to run when you are using a template macro, you need to add the TemplateFill macro command. The position of this command is important because macro execution is generally sequential. For example, if you want to insert a macro in a template that adds a date code to your document, you need to let the macro place the date code prior to your filling out the template prompts.


To insert a macro trigger in a template

WordPerfect Office btnbacktotopproc Triggering macros from templates
1.
 
Click File WordPerfect Office onestep Triggering macros from templates New from project.
2.
 
Choose a template from the Project list.
3.
 
Click Options WordPerfect Office onestep Triggering macros from templates Edit WP template.
4.
 
Click Associate on the Template toolbar.
5.
 
Enable the Triggers option.
6.
 
Choose a trigger from the Items to associate list.
7.
 
From the Macros list box, choose the macro you want to associate with the trigger.

WordPerfect Office note Triggering macros from templates

 
Only template macros that you have created in that template or copied to that template display in the Macros list box.

To add the TemplateFill macro command

WordPerfect Office btnbacktotopproc Triggering macros from templates
1.
 
Click Tools WordPerfect Office onestep Triggering macros from templates Macro WordPerfect Office onestep Triggering macros from templates Edit.
2.
 
Double-click a filename.
3.
 
Press Ctrl + End to place the cursor at the end of the macro document.
4.
 
Press Enter.
5.
 
Type TemplateFill().
6.
 
Click Save & compile on the Template macro toolbar.
7.
 
Choose the drive and folder where you want to save the macro.
8.
 
Type the filename in the Filename box.
9.
 
Click Options WordPerfect Office onestep Triggering macros from templates Close macro on the Template macro toolbar.

Triggering macros from templates