Found one small problem using AppleScript/Excel. I’m wondering if somebody can tell what’s wrong? Thanks in advance!
When a script (AppleScript) contains ‘tell’ block like this
tell application "Microsoft Excel"
end tell
the Xcode (like ScriptEditor) always saves path/reference to Excel within compiled script
at the origin Mac (where the program is compiled) (i.e. feature of AppleScript named
‘Applications are located lazily’ from
http://developer.apple.com/documentation/applescript/Conceptual/ApplescriptLangGuide/reference/ASLR_classes.html#//apple_ref/doc/uid/TP40000983-CH1g-SW2).
But when the customer has Excel installed to different location (like to the
‘Office 2008’ folder instead of default ‘Microsoft Office 2008’) any script-program with
block like above shows error message:
I’ve found an obvious solution - make property/variable := “Microsoft Excel” and work with
Excel from such block:
property MSXL : "Microsoft Excel"
tell application MSXL
launch
...
end tell
It works well while we are not accessing active sheet/book.
For example line with “active workbook” generates error at compile time. This script
doesn’t compile and generates an error “Expected end of line, etc. but found identifier.”
at the last (before end tell) line.
property MSXL : "Microsoft Excel"
tell application MSXL
launch
make new document
activate
set n to name of active workbook
end tell
while this scripts compiles perfectly:
--property MSXL : "Microsoft Excel"
tell application "Microsoft Excel"
launch
make new document
activate
set n to name of active workbook
end tell
Any ideas what I’m doing wrong?