Microsoft KB Archive/184282

= OFF97: Workbook_Open/Auto_Open Macros Are Run Twice in Binder =

Article ID: 184282

Article Last Modified on 6/18/2005

-

APPLIES TO


 * Microsoft Office 97 Standard Edition
 * Microsoft Excel 97 Standard Edition

-



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:

 On the Tools menu, point to Macro, and click Visual Basic Editor. Or, press ALT+F11. 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.  Modify the Workbook_Open macro, as in the following example: Private Sub Workbook_Open MsgBox "The workbook is open!" End Sub </ol> </li></ul>

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: kbbug KB184282

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.