Microsoft KB Archive/114647

= 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