Microsoft Knowledge Base

Excel: AppleScript: Evaluate Command Macro Errors

Last reviewed: June 2, 1997
Article ID: Q114647
4.00 MACINTOSH

The information in this article applies to:

  • Microsoft Excel for the Macintosh, version 4.0

SYMPTOMS

When you use the Evaluate command in AppleScript to run a Microsoft Excel macro, you may receive an error.

CAUSES/WORKAROUNDS

When you use the Evaluate command, you may receive an error for any of the following reasons:

   Cause              Workaround
   ------------------------------------------------------------------------

   Improper syntax    Check the syntax to be sure it is correct. An example
   such as using      of proper syntax would be as follows:
   A1 notation
   instead of R1C1       set myresult to (Evaluate "sum(!r1c1:r6c1)")
   notation is a
   common error.      This example will sum all the values in cells A1 to
                      A6.
   -or-

   The macro sheet    One way to ensure this is to issue an activate
   is not the active  command that activates the macro sheet before running
   document in        the macro. *For example, use the following:
   Microsoft Excel.
   When  attempting      set myresult to
   to run a Microsoft       (Evaluate "activate(\"scriptmacro\")")
   Excel macro, the      set myresult to (Evaluate "run(\"testscript\")")
   macro sheet that
   contains the
   macro must be
   active.

-or-

   The macro is not   Be sure the macro being run is properly defined.
   defined as a
   command macro.

* Type each command on a single line.

MORE INFORMATION

The Evaluate command allows AppleScript (or other Apple event-capable applications) to send a command or function to Microsoft Excel for evaluation. The results of the Evaluate command can be anything. If you pass one function or macro to Microsoft Excel, it returns one value. If you pass a list to Microsoft Excel, it returns a list. Examples of Evaluate commands are:

   set myresult to (Evaluate "2+2")
   set myresult to (Evaluate "sum(!r1c1:r6c1)")
   set myresult to (Evaluate "run(\"testscript\")")

For additional information on AppleScript, query on the following words in the Microsoft Knowledge Base:

   using and AppleScript and Excel and R1C1 and events

REFERENCES

"User's Guide 2," version 4.0, "Defining a Command Macro," page 236


KBCategory:
KBSubcategory:

Additional reference words: 4.00
Version : 4.00
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 2, 1997
©1997 Microsoft Corporation. All rights reserved. Legal Notices.