Microsoft KB Archive/71012

{|
 * width="100%"|

WD: How to Exit Windows from Word Using ExitWindows

 * }

Q71012

-

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

-

SUMMARY
You can use the ExitWindows macro command to exit Windows from Word for Windows. This command is not documented in the &quot;Microsoft Word Technical Reference for Word for Windows and OS/2&quot; (Word 1.x) or &quot;Using WordBasic&quot; (Word 2.0). It is documented in the &quot;Microsoft Word Developer's Kit&quot; for Word for Windows version 6.0 and for Word for Windows 95, version 7.0.

MORE INFORMATION
If you run a macro that includes the ExitWindows command, Word for Windows does NOT prompt you to save the document or global, glossary, and command changes. As a result, document modifications, glossaries, macros, and even the macro that calls the ExitWindows command itself can be lost if you run the ExitWindows command.

To use this command within Word for Windows and still be prompted to save any changes made during the current session, you can use an AutoExit macro to exit Windows when you exit Word for Windows. The AutoExit macro runs each time you close Word for Windows.

To create this macro, use the appropriate procedure below.

Word 7.0

 * 1) On the Tools menu, click Macro.
 * 2) In the Macro Name box, type AutoExit, and then click Create.
 * 3) On the line between Sub Main and End Sub, type ExitWindows. The complete macro should read as follows:
 * 4) On the File menu, click Close. When prompted to save changes, click Yes.
 * 5) On the File menu, click Save All. When prompted to save global glossary and command changes, click Yes.

Word 6.x

 * 1) On the Tools menu, click Macro.
 * 2) In the Macro Name box, type AutoExit, and then click Create.
 * 3) Type ExitWindows on the line between Sub Main and End Sub. The complete macro should read as follows:
 * 4) On the File menu, click Close. When prompted to save changes, click Yes.
 * 5) On the File menu, click Save All. When prompted to save global glossary and command changes, click Yes.

Word 2.x

 * 1) On the Tools menu, click Macro.
 * 2) In the Macro Name box, type AutoExit, and then click Edit.
 * 3) Type ExitWindows on the line between Sub Main and End Sub. The complete macro should read as follows:
 * 4) On the File menu, click Close. When prompted to save changes, click Yes.
 * 5) On the File menu, click Save All. When prompted to save global glossary and command changes, click Yes.

Word 1.x

 * 1) From the Macro menu, choose Edit.
 * 2) In the Edit Macro Name box, type AutoExit, then choose the OK button.
 * 3) Type ExitWindows on the line between Sub Main and End Sub. The complete macro should read as follows:
 * 4) From the File menu, choose Close. When prompted to keep changes to Global: autoexit, choose the Yes button.
 * 5) From the File menu, choose Exit. When prompted to save global glossary and command changes, choose the Yes button.