You are currently offline, waiting for your internet to reconnect

WD97: Auto Macros in Word

This article was previously published under Q70991
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
SUMMARY
Word reserves special names for macros that you can create to alter the wayWord behaves. These are called auto macros. The auto macros in MicrosoftWord are:

   AutoExec   AutoNew   AutoOpen   AutoClose   AutoExit				
MORE INFORMATION
Word recognizes a macro whose name begins with "Auto" as a macro that runsautomatically when the situation to which it applies arises. You supply theactual 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 keywhen you perform the action that triggers the macro.

NOTE: There are also a variety of startup switches that can be used withWord. For more information about startup switches, please see thefollowing article in the Microsoft Knowledge Base:
70014 WD: Word for Windows Startup Switches

Description of Auto Macros

AutoExec:

The AutoExec macro runs when you start Word. This macro makes it easy toinstruct Word to automatically make adjustments when you start Word. Forexample, you can create an AutoExec macro that automatically changes thedefault directory when you open Word for Windows.

For more information about how to change the default directory, please seethe following article in the Microsoft Knowledge Base:
110629 Macro to Change Default FileSaveAs Directory
The AutoExec macro runs when Word starts if the AutoExec macro was saved aspart of the default (Normal.dot) template or if it was saved as part of aglobal 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 currenttemplate. For example, an AutoNew macro could update all the fields in adocument, attached to a template of choice, and then run when you open anew document based on that template. The AutoNew macro runs when New isselected on the File menu in Word if the AutoNew macro was saved as part ofthe current template.

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

AutoOpen:

The AutoOpen macro runs after you open a file with the FileOpen or FileFindcommand, 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 on the File menu and theAutoOpen macro was saved as part of the current template.

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

AutoClose:

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

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

AutoExit:

The AutoExit macro runs when you quit Word.

The AutoExit macro runs when Word quits if the macro was saved as part ofthe default (Normal.dot) template or when saved as part of a template thathas 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 MacintoshEdition support global add-ins. Earlier versions of Word do not supportglobal add-ins.

For more information about global add-ins, click the Office Assistant, type"global" (without the quotation marks), click Search, and then click toview the "About global templates" topic.

NOTE: If the Assistant is hidden, click the Office Assistant button on theStandard toolbar. If Word Help is not installed on your computer, pleasesee the following article in the Microsoft Knowledge Base:
120802 Office: How to Add/Remove a Single Office Program or Component
filefind vbapps
Properties

Article ID: 70991 - Last Review: 11/16/2006 05:04:41 - Revision: 1.1

  • Microsoft Word 97 Standard Edition
  • kbfaq kbinfo kbmacro kbtemplate KB70991
Feedback