OFF97: Workbook_Open/Auto_Open Macros Are Run Twice in Binder (184282)



The information in this article applies to:

  • Microsoft Office 97 for Windows
  • Microsoft Excel 97 for Windows

This article was previously published under Q184282

SYMPTOMS

In Microsoft Binder, if you insert a Microsoft Excel workbook into a binder file by clicking Add From File on the Section menu, a macro in the workbook may be run twice.

CAUSE

This problem occurs when you first insert a workbook that contains a Workbook_Open or Auto_Open macro. Workbook_Open and Auto_Open macros are run automatically when you open a workbook.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed above.

MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. In Microsoft Excel 97, there are two methods that you can use to run a macro automatically when you open a workbook. These methods are as follows:

  • Create a macro named "Auto_Open," as in the following example:
          Sub Auto_Open()
              MsgBox "The workbook is open!"
          End Sub
    						
    You can store the macro in any Visual Basic module in the workbook. -or-

  • Create a Workbook_Open macro in the ThisWorkbook code window. To do this, follow these steps:

    1. On the Tools menu, point to Macro, and click Visual Basic Editor. Or, press ALT+F11.
    2. In the Project window, double-click the ThisWorkbook entry for the workbook. In the Code window, click Workbook in the Object list, and click Open in the Procedure list.
    3. Modify the Workbook_Open macro, as in the following example:
               Private Sub Workbook_Open()
                   MsgBox "The workbook is open!"
               End Sub
      								
When you insert a workbook into a binder and then activate the workbook section, the Workbook_Open and Auto_Open macros in the workbook run automatically.

Because of a problem in Microsoft Office Binder 97, the macros are run two times when you first insert the workbook into Binder. Also, if you have selected the Macro Virus Protection option in Microsoft Excel 97, you may be warned twice about macros in the workbook.

Modification Type:MajorLast Reviewed:6/18/2005
Keywords:kbbug KB184282