Article ID: 286310 - Last Review: March 30, 2007 - Revision: 5.1 Description of behaviors of AutoExec and AutoOpen macros in WordThis article was previously published under Q286310 SUMMARY You can use the AutoExec and AutoOpen macros in Word to establish default paths, styles, links,
environment conditions, and so on at the time Word opens a new document or
opens an existing document. This article discusses how these macros work and
how they behave in various situations. MORE INFORMATIONAutoExecAn AutoExec macro runs when Word starts if the AutoExec macro is saved as part of the default (Normal.dot) template, or if it is saved as part of a global add-in. By using an AutoExec macro, you can make adjustments when Word starts but before a document is created or loaded. For example, you can use an AutoExec macro to change the default directory when Word starts.You can suppress the AutoExec macro in several ways. One way is to start Word from the command line by using either the /m or the /embedding switch. To use these switches, click Start, click Run, type either winword /m or winword /embedding, and then click OK. Another method you may use to suppress an AutoExec macro is to press the Shift key while Word starts. AutoExec macros are also suppressed when Word is started from an Automation client. AutoOpenThe AutoOpen macro runs after you open a new document. AutoOpen runs when you open a document in the following ways:
You may prevent an AutoOpen macro from running by holding down the Shift key when you open a document. Create an AutoExec Macro and an AutoOpen MacroWord 2002 or Word 2003
Macro Behaviors in Different SituationsThe following table summarizes the behavior of these two macros when Word is started, or when a document is opened by various means:
Action AutoExec AutoOpen
---------------------------------------------------------------------------
Start Word with a blank document by typing Runs Does not run
the following at a command prompt:
Winword.exe
Start Word with a saved document by typing Runs Runs
the following at a command prompt:
Winword.exe C:\<Yourfile>.doc
Embed a Word document in an OLE container Does not run Runs
by typing the following at a command
prompt:
WinWord.exe /embedding C:\<Yourfile>.doc
Use code to automate Word and open Does not run Runs
C:\<Yourfile>.doc by using the following
code:
Set oWord = CreateObject("Word.Application")
oWord.Visible = True
oWord.Documents.Open "C:\YourFile.doc"
Browse to the document in Internet Explorer Does not run Runs
or the WebBrowser control
REFERENCES
For additional information about Auto macros in Word, click the following article numbers to view the articles in the Microsoft Knowledge Base:
211659
(http://support.microsoft.com/kb/211659/
)
WD2000: Auto Macros in Word
210565
(http://support.microsoft.com/kb/210565/
)
WD: Word
Startup (Command-Line) Switches and Their Purpose
(c) Microsoft Corporation 2001, All Rights
Reserved. Contributions by Chris Jensen, Microsoft Corporation.
| Article Translations
|
Back to the top
