Hi
Can’t find anything apart from a keystrokes (which are not allowed) and nothing in the dictionary seems to relate to this
I have a Numbers spreadsheet that I want to sort then choose a row manually.
tell application "Numbers"
activate
tell document 1 to tell sheet 1 to tell table 1
sort by column 1 direction ascending
end tell
end tell
The sort selects the column I am sorting and I need this to be deselected for the next script step.
Any clues, I would be most grateful
Here is the only way I was able to deselect a Numbers object.
my deselect()
on deselect()
# Utilise CliClick disponible à : http://www.bluem.net/en/mac/cliclick/
# scroll area 1 : area containing tables
# scroll area 2 : area containing the sheet titles
# if a table is selected we may have a 3rd scroll area
# scroll area 3 : area containing the inspectors
# if a cell is selected we may have 4 scroll areas
# scroll area 3 : area at the very bottom of the window used to display formulas
# scroll area 4 : area containing the inspectors
tell application "Numbers" to activate
tell application "System Events" to tell process "Numbers"
# Yosemite's activate take times to put the process at front.
# Explicitely put it get rid of that.
set frontmost to true
set theID to its id
-- log (get subrole of windows)
# Here we have Disposition and Colors floating windows open
-- (*AXFloatingWindow, AXFloatingWindow, AXStandardWindow*)
# We speak to a StandardWindow, not a Floating one
tell (first window whose subrole is "AXStandardWindow")
tell first scroll area
set {xLeft, yTop} to position
tell me to do shell script "/usr/bin/cliclick c:" & xLeft & "," & yTop
end tell
end tell
end tell
# tell (first process whose id is theID) # Useful if we must exit the block to do other tasks and enter an other System Events block
end deselect
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 27 janvier 2021 17:07:39
Hi,
The Numbers.app’s selection can’t be empty or missing value. To deselect some object in the Numbers.app you should select some other object, (which is not child object) of this object. Here is the way I founded playing with Numbers.app:
property |script| : "Select/Unselect cells or tables in the Numbers.app"
tell application "Numbers"
activate
make new document with properties {name:"test: Unselect a cell or a table thru AppleScript"}
end tell
-- select some cell
tell application "Numbers" to tell document 1 to tell active sheet to tell table 1 to set selection range to cell "B3"
delay 2
-- select cell's table (Unselects every cell)
tell application "Numbers" to tell document 1 to set selection to table 1 of active sheet
delay 2
-- select table's sheet (Unselects every cell and every table)
tell application "Numbers" to tell document 1 to set selection to active sheet
delay 5
Thank you for that effort Yvan but it does need clickclick installed. I am running this script on a number of different machines, so though possible is not really practicable.
If a man of your experience of AppleScript can only find a ‘keystroke’ solution then I think I might re think the architecture of that part of the script.
Ideally I would like to get all the data from Numbers saved into a plist then choose from list that data. But I am not clever enough to be able to parse the data correctly. The records consist on names, email addresses etc. The cells can contain spaces, more than one word and hyphens.
In pseudo code:
data collected from Numbers
coerce {{}{}{}} data to string of individual records
choose from list stringData
parse string to list keeping cell data integrity
save list as csv
and Thank You KniazidisR for the explanation. This is the line of code that I was looking for
tell application “Numbers” to tell document 1 to set selection to table 1 of active sheet