WD: ToolsMacro .Run Does Not Follow Context Hierarchy

ID: Q81027


The information in this article applies to:
  • Microsoft Word for Windows, versions 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows NT, version 6.0
  • Microsoft Word for the Macintosh, versions 6.0, 6.0.1


SUMMARY

In the Microsoft Word for Windows 2.x WordBasic macro language, the ToolsMacro .Run command is not designed to follow the context hierarchy prescribed for running Word for Windows macros. This is because the command corresponds to the Macro dialog box where the context is selected with an option button in the Show box.

In Word versions 6.x, 7.x, the ToolsMacro .Run command has an argument that is designed to follow the context hierarchy.


MORE INFORMATION

When you run a Word for Windows macro from the command line (ie. if you start Word by typing "WIN WINWORD /mMyMacro" at the MS-DOS prompt), Word looks for the macro first in the document template, then in Normal.dot, and finally in the built-in commands. This hierarchy holds even if the macro has the same name as a built-in command (such as FilePrint).

When you run a Word for Windows macro that has the same name as a built in command by calling its name in another macro, Word runs the built-in command.

If you run a macro using the ToolsMacro .Run WordBasic command and do not specify the .Show argument, the macro runs in the context specified the last time you chose Macro from the Tools menu.

Word versions 6.x, 7.x

If you run a macro using the ToolsMacro .Run command with the .Show argument 0, the macro runs according to Word's macro searching hierarchy. In the following example, Word looks for the macro first in the document template, then in Normal.dot, and finally in the built-in commands.

   ToolsMacro .Name = "mymacro", .Show = 0, .Run 

Word for Windows version 2.x

If you run a macro using the ToolsMacro .Run command without the .Show argument AND have not previously chosen Macro from the Tools menu, the .Show argument defaults according to the .Store argument in the Template dialog box (accessed by choosing Template from the File menu). The .Store argument corresponds to the options in the Store New Macros And Glossaries As box. The .Store argument corresponds as follows to the .Show argument:

   File Template                  Tools Macro
   -------------                  -----------
   Store New Macros and
   Glossaries as:                 Show:
      Global                         Global
      Template                       Template
      Prompt for Each New            Previous Setting 
If you want Word for Windows to follow the Template, Global, Built-in Command context hierarchy for macro execution in Word for Windows version 2.x (assuming the name is not the same as a built-in command), run your macro by calling its name rather than using the ToolsMacro statement.


REFERENCES

"Using WordBasic," by WexTech Systems and Microsoft, pages 210, 308

"Microsoft Word for Windows User's Guide," version 2.0, pages 705-706

Additional query words: winword2 wrong

Keywords : kbmacro kbprg kbdtacode kbtemplate wordnt winword ntword macword word6 word7 word95
Version : MACINTOSH:6.0,6.0.1; WINDOWS:2.0,2.0a,2.0a-CD,2.0b,2.0c,6.0,6.0a,6.0c; winnt:6.0
Platform : MACINTOSH WINDOWS winnt
Issue type : kbinfo


Last Reviewed: December 23, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.