DoScript(ScriptName As String, optional param1 As String, É)

 

Run an AppleScript on OSX.

 

The combination of XojoScripts and AppleScripts allows us to retrieve data from the database and send it to other applications for further processing. An example would be the creation and automatic filling of a letter or invoice form in Microsoft Word.

 

In order to launch an AppleScript from a XojoScript, one must previously have imported the AppleScript with Script Manager. See menu 'Script -> Script ManagerÉ'

 

If an AppleScript with ScriptName exists in the Scriptsfolder (see menu Administration -> Show Folder -> Script') then that script will be launched and optional string parameters (param1 to param10) will be passed to it. One can use up to 10 optional string parameters.

 

To study how to handle those parameters, select an example from the list of AppleScripts in Script Manager.

 

 

Parameters:

 

Name

Type

Description

ScriptName

String

Filename of AppleScript to launch, for example:

"WordInsertTextAtBookmark.scpt"

 Param1

String

Optional string sent to the AppleScript

 Param2

String

Optional string sent to the AppleScript

 Param3

String

Optional string sent to the AppleScript

 Param4

String

Optional string sent to the AppleScript

 Param5

String

Optional string sent to the AppleScript

 Param6

String

Optional string sent to the AppleScript

 Param7

String

Optional string sent to the AppleScript

 Param8

String

Optional string sent to the AppleScript

 Param9

String

Optional string sent to the AppleScript

 Param10

String

Optional string sent to the AppleScript

 

Available in:

 

WindowMain

WindowLink

YES

YES

 

 Used in:

 

XojoScript Name

GUID

Create letter in Word, from address

90AC7CD7-EE78-4659-8076-076E96B9EF5B

Create Cashregister list in Word

219A0572-0F50-4FBE-AFCE-1092181C8BEF

Print 24 labels on A4 from addresslist

51EEF5D2-24F3-413E-B82A-A3FC791EB73F

Print 24 labels of 1 address

ADF92843-E182-4410-B77D-70A7F4206B01

Print Addresslist in Word

A0503557-7DB7-4CC0-B08B-31005A0B1879

Create Seminar Invoice in Word

D2036EFA-D283-481A-9A93-D00547680749

 

Example Code:

 

Dim label As String

 

If GetPanelNum("imPanelBoxLabel") = 0 Then

label = GetText("imTA_adr_Label")

Else

label = GetText("imTA_adr_Label2")

End If

 

If Len(Trim(label))> 0 Then

Dim location As String = "Le Mont-Pelerin "

DoScript("WordLoadTemplate.scpt","imLetter.dotm")

DoScript("WordInsertTextAtBookmark.scpt", "bmLabel",label)

DoScript("WordInsertTextAtBookmark.scpt", "bmLocationDate",location)

DoScript("WordGotoBookmark.scpt", "bmStartWriting")

DoScript("WordInsertText.scpt", EOL+EOL)

DoScript("WordGotoBookmark.scpt", "bmStartWriting")

DoScript("WordInsertText.scpt", GetText("imTF_adr_Salutation"))

End If  // Len(Trim(label))> 0