WD: ToolsMacro .Run Does Not Follow Context Hierarchy

Last reviewed: February 2, 1998
Article 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
  • 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 : kbtemplate macword ntword winword word6 word7 word95 wordnt kbcode kbmacro kbprg
Version : WINDOWS:2.0,2.0a,2.0a-CD,2.0b,2.0c,6.0,6.0a,6.0c,7.0,7.0a; MACINTOSH:6.0,6.0.1,6.0.6.0.1a
Platform : MACINTOSH WINDOWS
Issue type : kbinfo


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 2, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.