When Keynote has more than one table, there appears to be no way to manipulate any table other than the first one.
activate application "Keynote"
tell application "Keynote"
tell the front document
tell the current slide
set tableCount to count of its tables
set auction to its last table
tell auction
set getName to its name
end tell
tableCount & getName
end tell
end tell
end tell
This returns {2, “Table 1”}
Any operations on the slide’s “Table 2” or “last table” apply only to the first table. Is there any way around this?
Model: Mini 5,3
AppleScript: 2.7
Browser: Safari 605.1.15
Operating System: macOS 10.13
Hi 4CardsMan.
A belated reply, but the name of a table mustn’t be confused with its index in the slide’s collection of tables. (The same applies with the names of tables and sheets in the Numbers application.)
I can reproduce your situation by adding a table to a table-less slide, changing the table’s default name from “Table 1” to something else (“Fred”, say), and then adding a second table. The second table will also take the name “Table 1”, since that name’s not in use at the time it’s created. But it’s still the second table in the slide:
tell application "Keynote"
tell the front document
tell the current slide
get {name of table 1, name of table 2} --> {"Fred", "Table 1"}
end tell
end tell
end tell
It may be too that subsequent edits will change the order of tables within a slide, but I can’t vouch for this.
I don’t know if any of the above is true for your tables, but confusion between the name “Table 1” and the specifier table 1 is something that’s come up before.
tell application “Keynote”
activate
tell the front document
tell the current slide
set theTable to its last table
end tell
end tell
end tell
returns this:
table 4 of slide 121 of document id “943898A4-EFC7-4A31-A76E-7D9C56A83252” of application “Keynote”
going further,
tell application “Keynote”
activate
tell the front document
tell the current slide
set theTable to its last table
tell theTable
its name
end tell
end tell
end tell
end tell
returns
“Table 3”
After more poking around, it appears that a calling a specific table number returns the table requested minus one. Calling the first table returns “Table 4”. This seems a little strange, but it is workable.