Calling Applescript using the MacScript()-function in Excel 11 is sometimes driving me crazy:
My script is calling curl via shell (snowleopard), parses the requested xml and puts the values in my excelsheet. All works fine with the script stored in my documents-folder and called in Excel-VBA with the MacScript-Function:
result = MacScript("MyScript.scpt").
Now I won't deploy several files, so i stored the script in an excel-cell and called it like that:
Dim scriptToRun As String
' -- "MyScript" is a named Excel-Cell here
scriptToRun = Range("MyScript").Value
result = MacScript(scriptToRun)
with very simple scripts this works fine too, but there are problems:
- with "on run...end run"-block the script is not executed. But how are functions defined without an on-run-block?
- set file_tgt to (POSIX path of(path to temporary items)) & "my.xml" leads to runtime-error 5
- "do shell script" leads to a runtime-error 5
All those commands are working well, when the script is saved as a file, but suck, when they are passed as a string. Does anyone know the reason for this strange behaviour? All suggestions (ecxept "burn down your mac") are welcome!