Microsoft KB Archive/112219

{|
 * width="100%"|

XL5: "Cannot Find Macro..." Using Run Method with Add-in Macro

 * }

-

The information in this article applies to:


 * Microsoft Excel for Windows, version 5.0

-

SYMPTOMS
In a Visual Basic module in Microsoft Excel, if you use the Run method of the Application object to run a macro located in an add-in, you may receive the following error message

Run-time error '1004':

Cannot find macro '!'

where  is the name of the add-in that contains the macro, and  is the name of the macro that you want to run.

CAUSE
This error occurs when the add-in that contains the procedure you used with the Run method is not currently open. Even if the add-in is fast loaded by the following line in the EXCEL5.INI file

"OPEN=/f C:\EXCEL\ADDIN.XLA" where ADDIN.XLA is the add-in file.

STATUS
Microsoft 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.

WORKAROUND
To use the Run method to run a macro that is contained in an add-in without receiving the error message above, do any of the following:

  In the procedure that contains the Run method, use the Open method of the Workbooks object to open the add-in before the Run method as in the following example: Workbooks.Open "c:\EXCEL\ADDIN.XLA"

Run("ADDIN.XLA!Macro_Name") -or-  Do the following to manually establish a reference to the add-in from the procedure that is calling the add-in macro:  Activate the module that contains the procedure that is running the add-in macro. From the Tools menu, choose References. If the add-in that contains the macro you want to run is not listed under Available References, choose Browse. From the File Name list, select the add-in you want to reference and choose OK. Choose OK again.</li></ol> </li></ul>

Microsoft provides examples of Visual Basic procedures 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 Visual Basic procedure is provided 'as is' and Microsoft does not guarantee that it can be used in all situations. Microsoft does not support modifications of this procedure to suit customer requirements for a particular purpose. Note that a line that is preceded by an apostrophe introduces a comment in the code--comments are provided to explain what the code is doing at a particular point in the procedure. Note also that an underscore character (_) indicates that code continues from one line to the next. You can type lines that contain this character as one logical line or you can divide the lines of code and include the line- continuation character. For more information about Visual Basic for Applications programming style, see the "Programming Style in This Manual" section in the "Document Conventions" section of the "Visual Basic User's Guide."

MORE INFORMATION
When you fast load an add-in, for example by using the /f switch in the EXCEL5.INI file as explained above, any menus and toolbars contained in the add-in are available, but the add-in file itself is not actually loaded, and any macros contained in the add-in are not loaded. When you demand load an add-in, either by opening the add-in file, or with the following line in the EXCEL5.INI file

<pre class="CODESAMP">OPEN C:\EXCEL5\ADDIN.XLA everything in the add-in is available, including any macros in the add-in. Therefore, when you demand load and add-in, you do not receive the above error message when you use the Run method to run a macro located in the add-in.

For more information about using the /F switch to load an add-in, query on the following words in the Microsoft Knowledge Base:

"fast and load and add-in" Additional query words: addins addin

Keywords :

Version : WINDOWS:5.0

Platform : WINDOWS

Issue type :

Technology :