Syntax
MacScript Script$
MacScript$(Script$)
Remarks
The MacScript statement runs an existing AppleScript script resource, or passes the specified string to the default scripting language to compile and run.
Argument | Explanation |
Script$ | The path and filename of a script file, or a string to compile and run. If you specify a script file, Word loads the file and runs the first script resource. |
The MacScript$() function behaves the same as the statement and also returns a string that corresponds to the value returned by the specified script. If the script returns a number, it is converted to a string. If the script does not return a value, MacScript$() returns an empty string ("").
In Windows, MacScript and MacScript$() are not available and generate errors.
Example
The following macro refers to a script called CalculateString. Suppose that this script takes the selected string in a Word document and sends it to Microsoft Excel, where Microsoft Excel attempts to evaluate the string as a formula. If Microsoft Excel can evaluate the formula, the script returns the value to Word as a string. Word can then replace the selection with the result.
Sub MAIN result$ = MacScript$("HD:APPLESCRIPT:SCRIPTS:CALCULATESTRING") If result$ <> "" Then EditCut Insert result$ End If End Sub
For more information on extending Word and WordBasic with AppleScript script resources, see Appendix D, "AppleScript," in Part 3, "Appendixes."
See Also
Call, Declare