How do you refer to an Excel macro, an application that interacts with an Excel spreadsheet?
I am working with an application that provides a scripting interface with AppleScript. I need to call this AppleScript script from within an Excel macro. The script should read information from the spreadsheet, feed it to the application, and update the spreadsheet based on the results. When I run AppleScript by itself, it works fine, but when called from a macro, the macro executes. Below is an example to illustrate the problem I am facing:
VBA macro:
Sub Test()
OSA = "/usr/bin/osascript"
SCRIPT = "/tmp/TestScript.scpt"
MacScript ("do shell script " & Chr(34) & OSA & " " & SCRIPT & Chr(34))
End Sub
TestScript.scpt
tell application "Microsoft Excel"
tell active sheet of active workbook
set value of range "A4:C5" to {{"a", "b", "c"}, {"d", "e", "f"}}
end tell
end tell
If I run this script by itself it works fine and updates the active sheet. But if I call it from a macro like above, I get a Runtime 5 error on the line calling the script from the macro.
Any idea how to do this?
source to share
This error indicates a problem with the VBA syntax, of course with a double quote. However, I would not run applescript to run a shell script to run applescript. Too many steps. Just run your script from macscript line:
macscript("run script file ""Macintosh HD:Users:private:tmp:TestScript.scpt""")
source to share