WD: How to Exit Windows from Word Using ExitWindows

Last reviewed: February 13, 1998
Article ID: 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 95, 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 "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          : kbhowto kbwordvba winword winword2 word6 word7 word95 kbmacro kbusage
Version           : WINDOWS: 1.x, 2.x, 6.0 6.0a 6.0c
Platform          : WINDOWS


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 13, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.