Auto_Close, Auto_Open Macros Not Executed in Excel

Last reviewed: August 20, 1995
Article ID: Q46350
The information in this article applies to:
  • Microsoft Excel for Windows, versions 2.x, 3.0, 4.0, 4.0, 5.0, 5.0c
  • Microsoft Excel for Windows 95, version 7.0

SUMMARY

An Auto_Open macro is a macro that is defined to automatically run when the sheet is opened.

An Auto_Close macro is a macro that is defined to automatically run when the sheet is closed.

These procedures work correctly when you open or close the sheet manually. However, if the sheet is opened or closed by another macro, the automatic macros will not be executed. This behavior is by design.

This is also true for Solver, Q+E, and all add-in macros included in the Microsoft Excel LIBRARY subdirectory. Because the Auto_Open macro does not run when you open these files from another macro sheet, you will be unable to execute any of the menu commands that these add-in macros supply.

Workaround

You can cause the Auto_Open macro to run by simply placing a RUN statement in the calling macro that then runs the Auto_Open macro. An example using the add-in FLATFILE.XLA macro is shown below:

   A2:=OPEN("Flatfile.xla")
   A3:=RUN(Flatfile.xla!Auto_Open)

After executing the RUN statement, you are then able to run any menu commands that FLATFILE.XLA normally supplies.

REFERENCES

"Microsoft Excel User's Guide," version 3.0, page 676


KBCategory: kbusage
KBSubcategory:

Additional reference words: 7.00 2.00 2.01 2.10 2.10c 2.10d 3.00 3.0 2.1d
2.1c 2.1 2.0


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: August 20, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.