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


Additional query words: 5.00 Apple Script
Keywords : kbprg PgmOthr xlmac kbcode kbenv
Version : 5.00 5.00a
Platform : MACINTOSH


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 13, 1997
©1997 Microsoft Corporation. All rights reserved. Legal Notices.