Auto_Close, Auto_Open Macros Not Executed in Excel

ID: Q46350


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

Additional query words: 2.00 2.01 2.10 2.10c 2.10d 3.0 2.1d 2.1c 2.1 2.0

Keywords :
Version :
Platform :
Issue type :


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