Microsoft KB Archive/99003

= Microsoft Knowledge Base =

Excel: SHIFT+Close All Does Not Bypass Auto_Close Macros
Last reviewed: September 12, 1996

Article ID: Q99003

The information in this article applies to:


 * Microsoft Excel for Windows, versions 3.0, 4.0, 4.0a, 5.0
 * Microsoft Excel for OS/2, version 3.0
 * Microsoft Excel for the Macintosh, versions 3.0, 4.0, 5.0

SUMMARY
In Microsoft Excel, if you choose Close All, you will automatically start any Auto_Close macros that are assigned to any open worksheets or macro sheets. This is by design.

Note: To display the Close All command, hold down SHIFT and choose the File menu.

MORE INFORMATION
In a Microsoft Excel worksheet or macro sheet, you can cause a macro to run automatically when you close the file by referring to that macro with a defined name that starts with Auto_Close. For example, if you define the formula =MACRO1.XLM!$A$1 with the name Auto_Close, when you close the worksheet, the macro that starts in cell A1 of MACRO1.XLM will automatically run.

You can bypass the execution of an Auto_Close macro by holding down the SHIFT key when you close the file. For example, in Microsoft Excel for Windows, if you hold down the SHIFT key and double-click the control menu, the worksheet will close without running the Auto_Close macro.

Microsoft Excel also allows you to close all open documents by holding down the SHIFT key and choosing Close All from the File menu. However, if you choose Close All, all Auto_Close macros that are assigned to open documents will be executed.

Workarounds
To bypass an Auto_Close macro, use one of the following procedures:

 On the keyboard, hold down the SHIFT key and double-click the control menu on the worksheet (Microsoft Excel for Windows and Microsoft Excel for OS/2) or click the close box in the upper-left corner of the worksheet (Microsoft Excel for the Macintosh). -or- Choose the File menu. Then, hold down the SHIFT key and choose Close.

There is no way to close all documents with the Close All command AND bypass Auto_Close macros at the same time.