WD: AutoClose Macro Is Executed Before Document Is Closed

ID: Q41735

The information in this article applies to:

SUMMARY

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.

MORE INFORMATION

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

REFERENCES

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

Additional query words:

Keywords          : kbmacro winword macword word6 winword2 word7 word95 
Version           : WINDOWS:6.0,6.0a,6.0c,7.0,7.0a; MACINTOSH:6.0,6.0.1,6.0.1a
Platform          : MACINTOSH WINDOWS
Issue type        : kbinfo

Last Reviewed: April 22, 1998