Re: Numbers '08 (Selection range)
Re: Numbers '08 (Selection range)
- Subject: Re: Numbers '08 (Selection range)
- From: "Scott Lindsey" <email@hidden>
- Date: Mon, 12 Jan 2009 21:23:29 -0800 (PST)
- Importance: Normal
Stockly, Ed wrote:
> This version does the same thing, and may be a bit faster, but is still
pretty ugly.
It only works with one table per sheet. You need an inner repeat loop,
such as:
tell application "Numbers"
tell document 1
set mySelectedRanges to selection range of every table of every sheet
whose it is not missing value
repeat with sheetRanges in mySelectedRanges
repeat with thisRange in sheetRanges
if contents of thisRange is not missing value then
try
--return thisRange --poorly formed result
thisRange as text
on error errMsg number errNum
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"\""}
set myRange to text item 2 of errMsg
set myTable to text item 4 of errMsg
set mySheet to text item 6 of errMsg
set myDoc to text item 8 of errMsg
set mySelection to (a reference to (range myRange of table myTable
of sheet mySheet))
set AppleScript's text item delimiters to oldDelims
return mySelection
end try
end if
end repeat
end repeat
end tell
end tell
At this point, both yours and mine are doing similar things, looping
through each sheet, looping through each table.
Yours works around the problematic return value: «class » ..., which I
failed to realize meant that my "or do something useful" really couldn't.
But you can throw the same try, coercion, and parsing of the error into
mine. I agree that it seems like yours might be a little faster, since it
gets back a bunch of results, and loops through them, instead of looping
and sending a separate request for each sheet and each table.
In fact, I just created a large document with over 200 tables, and there's
a noticeable difference in speed. Mine takes around 6 seconds, and yours
less than 1.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden