Has anyone had any luck with accessing and/or retrieving data from user-selected cells in an AW spreadsheet? I looked in the Applescript Usage Notes that come with AW, and this is the code they recommended:
tell application "AppleWorks 6"
tell front document
get properties of selection --This is straight from the AW usage notes file and crashes every time in the SS, regardless of how many cells are selected. Rats.
end tell
end tell
--It does return some interesting stuff when using the WP, however.
As you can see from comments, it works great on selected text in the WP, but crashes AppleWorks every time I try to use it in the SS. I have NOT tried putting this inside of a try block yet; I am assuming that I have some kind of syntax issue. I have tried things like setting the selection to a variable, setting the contents of selected cells to variables, etc.
My eventual goal is to create a script that takes the cells a user selects and accesses the data in those cells for processing. I have most of that script finished and am currently using the clipboard by simply copying the selected cells and then accessing the data from there. If I could skip that step, however, it would be most excellent.
Craig Smith
Model: Powermac dual G4
AppleScript: 1.9.3
Browser: Firefox 1.0
Operating System: Mac OS X (10.3.9)
Thanks a lot. Of course, it works just fine now. I was stuck on the whole [tell front document] thing, and never thought to try just set the varible to the selection and go home! I am constantly amazed at how many simple solutions exist, once somebody offers a gentle reminder to think outside the nested tell.
You are absolultely correct about AppleWorks being a scripting challenge. I have done pretty well so far just using the scripting documentation included, although even that was not easy to locate. I am really having fun with that [object specifier] command you passed along; where did you get that? My two primary references are the Beginning Applescript by Steve Kochan and the Applescript text by Haanan Rosenthal. Is there another resource out there I should get my hands on?
The AppleWorks dictionary shows certain objects that have the ‘object specifier’ property. Many objects inherit this property from other objects such as ‘graphic object’, ‘cell’, etc.