Microsoft KB Archive/115392

= 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:


 * Microsoft Excel for Windows, versions 5.0, 5.0c
 * Microsoft Excel for Windows 95, version 7.0
 * Microsoft Excel for the Macintosh, version 5.0

SYMPTOMS
In 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.

CAUSE
You 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

WORKAROUND
To 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

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