Excel: Exiting Windows from a Command Macro

Last reviewed: September 2, 1997
Article ID: Q77976

The information in this article applies to:
  • Microsoft Excel for Windows, versions 2.x, 3.0, 4.0, 5.0

SUMMARY

IMPORTANT: The CALL and REGISTER functions are provided for advanced users only. If you use these functions incorrectly you may accidentally cause errors in your system's operation.

The following macro fragment will exit Windows whan it is run:

A1: =REGISTER("USER","ExitWindows","AJI") A2: =CALL(A1,1,0)

This will cause Windows to close all open applications immediately and return to MS-DOS.

MORE INFORMATION

WARNING: Sheets being edited in the current instance of Microsoft Excel (the instance from which the macro is run) will be closed without confirmation. You will lose any changes made since the last time your files were saved. Other Windows applications and instances of Microsoft Excel will ask for confirmation just as if you had exited Windows manually.

The macro statement shown above actually makes a call to a Windows DLL (dynamic-link library) in the same way that using the Exit option on the File menu of Program Manager would. Each application must agree to be closed (for example, if you choose Cancel when an application asks you if you want to save a file, the exit request also is canceled).

REFERENCES

"User's Guide 2," version 4.0, pages 231-238

"Microsoft Excel User's Guide," version 3.0, pages 595-600

"Microsoft Windows Software Development Kit Reference - Volume 1," version 3.0, page 3-6


Additional query words: 2.0 2.00 2.01 2.1 2.10 2.2 2.20 2.21 3.0 3.00
4.0 4.00 5.0 5.00 SDK dynamic link
Keywords : PgmHowTo PgmOthr


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: September 2, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.