Microsoft KB Archive/137903

= Microsoft Knowledge Base =

MXL5: Range Method Fails Calling Macro from AppleScript
Last reviewed: June 13, 1997

Article ID: Q137903

The information in this article applies to:


 * Microsoft Excel for the Macintosh, versions 5.0, 5.0a

SYMPTOMS
When you attempt to run a Microsoft Excel macro from an AppleScript script, you may receive the following error message in AppleScript:

Execution Error

Microsoft Excel got an error: AppleEvent timed out. In addition, when you activate Microsoft Excel, you may see an error message similar to the following:

Macro Error

Run-time error '1004' Range method of Application class failed

CAUSE
You may receive either or both of the error messages described above if your Microsoft Excel macro uses the Range method.

WORKAROUND
To avoid this problem, eliminate all references to the Range method from the macro before you call that macro from AppleScript. One alternative to the Range method is the Cells method. For example, instead of using

Range("A1").Select you could use:

Cells(1,1).Select

MORE INFORMATION
The Range method is a method of the Application class that allows a macro programmer to refer to a specific range of cells on a worksheet. This method works well in a Visual Basic for applications macro when it's called in Microsoft Excel. However, if the macro is called from AppleScript, the Range method may fail.

For additional information, please see the following article(s) in the Microsoft Knowledge Base:

ARTICLE-ID: Q126045 TITLE    : MXL5: Range Method May Fail When Used in Auto_Open Macro

ARTICLE-ID: Q132437 TITLE    : Calling Excel Macros and Functions from AppleScript