WD: How to Exit Windows from Word Using ExitWindows

ID: Q71012

The information in this article applies to:

SUMMARY

You can use the ExitWindows macro command to exit Windows from Word for Windows. This command is not documented in the "Microsoft Word Technical Reference for Word for Windows and OS/2" (Word 1.x) or "Using WordBasic" (Word 2.0). It is documented in the "Microsoft Word Developer's Kit" 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" (without the quotation

   marks), and then click Create.

3. On the line between Sub Main and End Sub, type "ExitWindows" (without
   the quotation marks). The complete macro should read as follows:

      Sub Main
         ExitWindows
      End Sub

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" (without the quotation

   marks), and then click Create.

3. Type "ExitWindows" (without the quotation marks) on the line
   between Sub Main and End Sub. The complete macro should read as
   follows:

   Sub Main
      ExitWindows
   End Sub

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" (without the quotation

   marks), and then click Edit.

3. Type "ExitWindows" (without the quotation marks) on the line
   between Sub Main and End Sub. The complete macro should read as
   follows:

   Sub Main
      ExitWindows
   End Sub

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" (without the quotation

   marks), then choose the OK button.

3. Type "ExitWindows" (without the quotation marks) on the line
   between Sub Main and End Sub. The complete macro should read as
   follows:

   Sub Main
      ExitWindows
   End Sub

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.

REFERENCES

"Microsoft Word for Windows User's Reference," version 1.x, pages 187-189

Keywords          : kbmacro kbusage kbwordvba winword word6 winword2 word7 word95 kbhowto 
Version           : WINDOWS:1.0,1.1,1.1a,2.0,2.0a,2.0a-CD,2.0b,2.0c,6.0,6.0a,6.0c,7.0,7.0a
Platform          : WINDOWS

Last Reviewed: February 1, 1999