Understand How PLAY Instructions Work in RTF Templates

From HotDocs Wiki

Jump to: navigation, search

The PLAY "MACRO" instruction plays a word processor macro after the document is assembled and either sent to the word processor, printed, or saved.

Where you store the macro depends on which word processor you are using:

  • For WordPerfect users, the macro can be stored anywhere. The PLAY instruction must include the file name of the macro, and if the macro is stored anywhere other than the default macro folder, the instruction must include a full path to the file as well.
  • For Word DOT users, the macro must be stored in the template itself, in Normal.dot, or in any global template that is automatically loaded when you start Word.
  • For Word RTF users, the macro must be stored either in Normal.dot, in any global template that is automatically loaded when you start Word, or in a .DOT referenced by the template's component file (HotDocs 2006 and later users).

If you use a PLAY "MACRO" instruction in a Word RTF template, HotDocs must be able to find the macro to play when it saves the assembled document or sends it to the word processor. The macro must be saved in a DOT file somewhere where Word can find it. These locations include:

  1. Any DOT file that is in the Word Startup folder. This is the same place where the HotDocs global templates Hd6edit.dot and Hd6icon.dot are stored. All DOT files in the Word Startup folder are loaded into Word when it starts, so any macros they contain are found.
  2. Normal.dot. When Word starts up, it looks in its default templates folder for Normal.dot and loads it. Any macros contained in Normal.dot are available to HotDocs when it executes a PLAY instruction.
  3. The template upon which a document is based. If you edit a document in Word and then choose Tools > Templates and Add-Ins, you'll see a Document template box that lists the template upon which the document is based. Most documents are based on Normal by default. If you edit a HotDocs template (either DOT or RTF), you'll see that it is based on Hotdocs6.dot. If you check Templates and Add-Ins for a document assembled from HotDocs, you'll see it says it is based on Normal. What you don't see is that after HotDocs assembles a document, if the document contains any PLAY instructions, HotDocs temporarily switches the base template for the assembled document to the HotDocs template from which it was assembled, then switches back to Normal after the PLAY instructions are finished. Thus, any macros contained in the original HotDocs template are available to be PLAYed in the assembled document.
  4. HotDocs 2006 (and later) users: Any DOT file that is saved in the same folder as the template and referenced from the template's Component File Properties. (See the Hotdocs Help for more detials.)

PLAY instructions are executed any time you create an actual document from the assembly. This includes sending the document to the word processor, saving the document, or printing a copy of the document.