Excel: Exiting Windows from a Command Macro

ID: Q77976


The information in this article applies to:
  • Microsoft Excel for Windows, versions 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:

Keywords :
Version : WINDOWS:3.0,4.0,5.0
Platform : WINDOWS
Issue type :


Last Reviewed: October 29, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.