Microsoft KB Archive/28870

Online Tutorial Causes Auto_Open Macro to Run Again in Excel PSS ID Number: Q28870 Article last modified on 02-26-1993 PSS database name: W_eXceL

2.x 3.00

WINDOWS

Summary:

If you create an Auto_Open macro that adds a menu to the formula bar, and then run the macro, the menu is added. However, if you then run the Tutorial and return to Excel, the Auto_Open macro runs again and a second menu is added to the formula bar.

This problem does not occur with Microsoft Excel version 4.0.

More Information:

This problem is due to the interaction of two separate actions:


 * 1) By design, an Auto_Open macro executes its commands each time the sheet on which it is declared is opened.
 * 2) The Tutorial first closes all open documents when it begins and keeps a list so that it can return Excel to the same state it was in when the Tutorial was invoked. When the Tutorial is finished, it returns Excel to its original state by reopening those documents that were open when the Tutorial was started.

In the scenario above, a document containing an Auto_Open macro is opened. The macro adds a menu to the menu bar as it was designed to. When the Tutorial runs, it closes all documents that are open. When the Tutorial finishes, it returns Excel to the state it was in when the Tutorial was started. In doing so, the document containing the Auto_Open macro is opened, causing the Auto_Open macro to properly run again. This results in a second menu being added to the menu bar.

Copyright Microsoft Corporation 1993.