PDA

View Full Version : Numbers Scriptability


NovaScotian
01-01-2011, 01:45 PM
Is Numbers '09 running in Leopard AppleScriptable? It shows a dictionary, but I can't manage to get the selected cell of table 1 of sheet 1 of window 1. Have I got the tree wrong?

renaultssoftware
01-01-2011, 02:15 PM
I don't think you can get the selected cell. You can get the selection range, which is about the same thing:

tell application "Numbers" to get the selection range of table 1 of sheet 1 of document 1
-- result: «class » "B3:D12" of table "Table 1" of sheet "Sheet 1" of document "Untitled" of application "Numbers"

NovaScotian
01-01-2011, 02:56 PM
Thanks, Renault. That actually makes it unscriptable though. That leading «class » part means that you can't set an understandable variable to the range. For example:

set F to format of (get selection range) gets an error: "Numbers got an error: Can’t make «class " and it stops there. Ugh.

I suppose this might work in Snow Leopard, but I want the big screen on my G5 machine, not a laptop screen.

renaultssoftware
01-01-2011, 03:00 PM
There is a class for the selection (range) in the sdef. I saw it earlier. :confused:

NovaScotian
01-01-2011, 03:59 PM
I think the problem is the space: «class »; a bug perhaps.

renaultssoftware
01-01-2011, 04:05 PM
Strangely,
tell application "Numbers" to get the class of the selection range of table 1 of sheet 1 of document 1
-- returns: range

jeffshenk
01-03-2011, 08:13 AM
The following worked for me:

tell application "Numbers"
tell table 1 of sheet 1 of front document
set F to (get format of (a reference to (its selection range)))
F
end tell
end tell
--returns: checkbox

If more than one cell is selected, this returns the format for the first cell in the range.

tw
01-03-2011, 08:54 AM
try:
tell application "Numbers"
get the value of every cell of the selection range of table 1 of sheet 1 of document 1
end tell
that should return a list of the values of all the cells in the selection. if there's only one cell selected, it will return a list of one item.

NovaScotian
01-03-2011, 09:07 AM
Thanks, TW -- I just got there yesterday; for a single selected cell, the command must include cell 1 or cells.