OFF97: Workbook_Open/Auto_Open Macros Are Run Twice in Binder

ID: Q184282


The information in this article applies to:
  • Microsoft Office 97 for Windows
  • Microsoft Excel 97 for Windows


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, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft Support professionals 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 needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

http://www.microsoft.com/support/supportnet/overview/overview.asp
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.

Additional query words: OFF97 XL97

Keywords : xlvbainfo OffVBA offbinder
Version : WINDOWS:97
Platform : WINDOWS
Issue type : kbbug


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