ID: Q119887
The information in this article applies to:
This article contains an AppleScript example that demonstrates the use of the following WordBasic statement and function:
MacScript
MacScript$()
This article supplements the information in online Help. To open this Help
topic, choose the Help button on your keyboard, select the Programming With
Microsoft Word option, and type "macscript" (without quotation marks) on
the query line.
WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
MacScript Script$
MacScript$(Script$)
Script$ is the path and filename of a script or a text string that will
be compiled and run by AppleScript.
The MacScript statement runs an existing AppleScript script or passes a
text string to AppleScript that will be interpreted by AppleScript.
The MacScript$() function behaves the same as the MacScript statement and also returns the value returned by Script$. The MacScript$() function always return a string. If the script specified by Script$ returns anything other than a string, it is converted to a string by MacScript$(). If the script specified by Script$ does not return a value, the MacScript$() returns the empty string("").
In Windows, the MacScript statement and MacScript$() function are not available and generate errors.
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 tries to evaluate the string as a formula. If Microsoft Excel can evaluate the formula, the script returns the value to Word as a string. The WordBasic macro can then replace the selection with the contents of result$.
Sub MAIN:
result$ = MacScript$("HD:APPLESCRIPT:SCRIPTS:CALCULATESTRING")
If result$ <> "" Then
EditCut
Insert result$
End If
End Sub
"Microsoft Word Developer's Kit," version 6.0, Microsoft Press, 1994, Appendix D, "AppleScript"
Additional query words: word basic
Keywords : kbmacro kbmacroexample macword word6
Version : MACINTOSH:6.0,6.0.1,6.0.1a
Platform : MACINTOSH
Issue type : kbinfo
Last Reviewed: February 7, 1998