top of page

108. Running a Macro During Assembly

Description

How to run a macro during assembly.

Code

Explanation

You can play a word processor macro during document assembly by inserting a PLAY instruction into the template.

To insert a PLAY instruction:

Position the cursor at the point in the template where you want the macro to be run.
Insert a HotDocs variable or instruction (to insert the correct chevron characters).
Delete the text between the chevrons and replace it with PLAY "macroname" (where macroname is the name of the macro). Be sure to use straight quotes (" ") instead of curly or smart quotes.
In WordPerfect or Ami Pro, macroname can be a file name (if the macro is stored in the default macro directory) or a full path (if it is not). For example: MYMACRO.WCM or C:\TEMP\MYMACRO.WCM.

In Word, macroname is just a macro name. The macro may be stored in the template you are editing, or it may be stored in a global template (such as HDGLOBAL.DOT) or in NORMAL.DOT. In Word and Ami Pro, and in WordPerfect templates assembled in the word processor (slow-assembled), PLAY instructions are executed as they are encountered. For WordPerfect templates that are assembled from the HotDocs library (fast-assembled), PLAY instructions are stored until assembly is complete, then the assembled document is loaded into the word processor and the stored PLAY instructions are executed. This means that WordPerfect templates with PLAY instructions operate differently depending on how they are assembled, unless the PLAY instructions are placed at the end of the template.

You should be careful that the macro used with a PLAY instruction doesn't change the active cursor location, or HotDocs may skip over some text of the template that needs to be processed for assembly.

bottom of page