WD: Auto Macros in Word

Last reviewed: March 6, 1998
Article ID: Q70991
The information in this article applies to:
  • Microsoft Word for Windows, versions 1.0, 1.1, 1.1a, 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
  • Microsoft Word for Windows 95, versions 7.0, 7.0a
  • Microsoft Word 97 for Windows
  • Microsoft Word 98 Macintosh Edition

SUMMARY

Word reserves special names for macros that you can create to alter the way Word behaves. These are called auto macros. The auto macros in Microsoft Word are:

   AutoExec
   AutoNew
   AutoOpen
   AutoClose
   AutoExit

MORE INFORMATION

Word recognizes a macro whose name begins with "Auto" as a macro that runs automatically when the situation to which it applies arises. You supply the actual steps for the auto macro by either writing or recording the macro.

You can prevent an auto macro from running by holding down the SHIFT key when you perform the action that triggers the macro.

NOTE: There are also a variety of start-up switches that can be used with Word. For more information regarding startup switches, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q70014
   TITLE     : Word for Windows Startup Switches

Description of Auto Macros

AutoExec:

The AutoExec macro runs when you start Word. This macro makes it easy to instruct Word to automatically make adjustments when you start Word. For example, you can create an AutoExec macro that automatically changes the default directory when you open Word for Windows.

For more information on how to change the default directory, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q110629
   TITLE     : Macro to Change Default FileSaveAs Directory

The AutoExec macro runs when Word starts if the AutoExec macro was saved as part of the default (Normal.dot) template or if it was saved as part of a global add-in.

To prevent AutoExec from running, type

 winword /m

into a command prompt to start Word.

AutoNew:

The AutoNew macro runs after you create a new document based on a current template. For example, an AutoNew macro could update all the fields in a document, attached to a template of choice, and then run when you open a new document based on that template. The AutoNew macro runs when New is selected on the File menu in Word if the AutoNew macro was saved as part of the current template.

The AutoNew macro does not run if the AutoNew macro was saved as part of a global add-in. The AutoNew macro is available when selecting Macros from the Tools menu.

AutoOpen:

The AutoOpen macro runs after you open a file with the FileOpen or FileFind command, or from the list of the last four documents that were opened (see the bottom of the File menu).

The AutoOpen macro runs when Open is selected from the File menu and the AutoOpen macro was saved as part of the current template.

The AutoOpen macro does not run if the AutoOpen macro was saved as part of a global add-in. The AutoOpen macro is available when Macros is selected on the Tools menu.

AutoClose:

The AutoClose macro runs when you close a document. The AutoClose macro will run when Close is selected on the File menu and the AutoClose macro was saved as part of the current template.

The AutoClose macro will not run if the macro was saved as part of a global add-in. The AutoClose macro is available when Macros is selected on the Tools menu.

AutoExit:

The AutoExit macro runs when you quit Word.

The AutoExit macro runs when Word exits if the macro was saved as part of the default (Normal.dot) template or when saved as part of a template that has been added into the Startup folder or added as a global template.

REFERENCES

"Microsoft Word for Windows Technical Reference," pages 7-8

"Microsoft Word for Windows and OS/2 Technical Reference," pages 97-99

"Using WordBasic," by WexTech Systems and Microsoft, pages 84-87.

"Microsoft Word Developers Kit," Third Edition, pages 35-37.

NOTE: Only Microsoft Word versions 6.0, 7.0, Word 97 and Word 98 Macintosh Edition support global add-ins. Earlier versions of Word do not support global add-ins.

For more information about global add-ins, please refer to the following sources.

Word 97 for Windows or Word 98 Macintosh Edition

Click the Office Assistant, type "global" (without the quotation marks), click Search, and then click to view the "About global templates" topic.

NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If Word Help is not installed on your computer, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q120802
   TITLE     : Office: How to Add/Remove a Single Office Program or
               Component

Word 7.x

Click "Microsoft Word Help Topics" on the Help menu. Click the Find tab and type in "global" (without the quotation marks) for step one. Select "global-template" for step two and click Display.

Word 6.x

Microsoft Word 6.0 "Users Guide," Chapter 10, pages 220-224

Click "Search for Help on..." on the Help menu. Type "global" (without the quotation marks). Select "global templates" and click Show Topics. Select "Loading a template as a global template" and click Go To.


Additional query words: filefind
Keywords : kbtemplate macword ntword winword word6 word7 word8 word95 word97 wordnt macword98 kbmacro kbfaq
Version : WINDOWS: 1.0, 1.1, 1.1a, 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c, 7.0, 7.0a, 97; MACINTOSH: 6.0, 6.0.1, 98
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: March 6, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.