XL5: "Cannot Find Macro" Running Macro in Active WorkbookLast reviewed: September 12, 1996Article ID: Q115905 |
The information in this article applies to:
SYMPTOMSIn a Visual Basic macro in Microsoft Excel, if you activate a sheet in another workbook, and you use the Run method to run a macro in the activated workbook, such as SHEET1!Auto_Activate, you receive the following error message:
Run-time error '1004': Cannot find macro 'SHEET1!Auto_Activate'. CAUSEThis error occurs if you use the Run method to run a macro contained in another workbook, and you do not include the workbook name with the name of the macro you want to run. The error occurs because, by default, the Run method tries to find the macro name you specify within the workbook that contains the code that is running, not the active workbook. For example, if you run a macro in BOOK1.XLS, that activates a sheet in BOOK2.XLS, and uses the Run method to run a macro contained in BOOK2.XLS, you must include the book name BOOK2.XLS with the macro name in the Run method command to run the macro.
STATUSMicrosoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem was corrected in Microsoft Excel for Windows version 5.0c.
WORKAROUNDTo avoid receiving this error message when you use the Run method to run a macro in a workbook other than the workbook that contains the current code, do either of the following:
REFERENCESFor more information about the ActiveWorkbook Property, choose the Search button in the Visual Basic Reference and type:
ActiveWorkbook PropertyFor more information about the Run Method, choose the Search button in the Visual Basic Reference and type:
Run Method |
KBCategory: kbprb
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |