Microsoft KB Archive/77976

{|
 * width="100%"|

Excel: Exiting Windows from a Command Macro

 * }

-

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(&quot;USER&quot;,&quot;ExitWindows&quot;,&quot;AJI&quot;)

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).