Microsoft KB Archive/41735

From BetaArchive Wiki

AutoClose Macro Is Executed Before Document Is Closed


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, versions 7.0, 7.0a
  • Microsoft Word for the Macintosh, versions 6.0, 6.0.1


In Microsoft Word, an AutoClose macro is run when you close a document. However, if changes have been made to the document since the last time it was saved, Word prompts you to save the changes after the AutoClose macro has finished running.

If you want the document to be closed without having Word display the save message, include a command in your AutoClose macro to save the edited document without issuing this prompt.


WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

Use the "FileSaveAll 1" command to save all edited documents automatically without prompting. If the document has never been saved, Word will prompt for a location and name for the document. For example:

NOTE: This macro example must be named AutoClose.

Sub Main
  FileSaveAll 1
End Sub 


"Using WordBasic," by WexTech Systems and Microsoft Corporation, page 208

Additional query words:

Keywords : kbmacro kbdta winword macword word6 winword2 word7 word95
Issue type : kbinfo
Technology :

Last Reviewed: November 4, 2000
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.