Microsoft Knowledge Base |
|
"Cannot Find Macro" Calling Macro with Undefined User Type |
|
|
Last reviewed: July 2, 1997
Article ID: Q115392 |
|
The information in this article applies to:
SYMPTOMSIn Microsoft Excel, when you use the Run method of the Application object to run a macro contained in another module, and the macro you are running contains an undefined user-defined type, you receive the following error message
Run-time error '1004': Cannot find macro 'Macro_Name'.where Macro_Name is the name of the macro that you called using the Run method.
CAUSEYou receive this error message, even if the macro you are calling exists and is available, if that macro contains a user-defined type that has not been defined or a type declaration that is misspelled. Take for example the following Test macro contained in Module1:
Sub Test()
Dim X As Integers
End Sub
Because Integers is not a built-in data type (note that "Integer" without
the "s" is a built-in data type), it is considered a user-defined type.
Further, because it is not defined with a Type statement, it is an
undefined user-defined type. If you then call the macro "Test" in Module1,
using the Run method from the macro "Run_Test" in Module2, you receive the
error message above, even though the macro does exist and is available.
This error message also appears if the undefined user-defined type is an argument for the macro as in the following example:
Sub Test(X As Integers) End Sub WORKAROUNDTo avoid receiving this error message when you run a macro contained in another module, you must fix the error involving the user-defined type, either by using the Type statement to define the user-defined type, or by correcting a syntax error in the data type. Note that if you call the macro using just the macro name, or by using the Call statement, you receive the following correct error message:
User-defined type not defined STATUSMicrosoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
REFERENCESFor more information about the Type Statement, choose the Search button in Help and type:
Type |
|
Additional query words: 1.00 5.00 5.00a 5.00c 7.00 xl5
©1997 Microsoft Corporation. All rights reserved. Legal Notices. |