Editing existing tables usually requires the initial step of identifying the table(s) to be edited. A script can search every slide of a document looking for a particular table whose property values match specific criteria, such as name, or cell|row|column count. Most often however, scripts run by users are executed on the currently selected table in a document.
The following script can function as a template for scripts you write that target a selected table. The script includes checks for an open document, and for a selected table. To use, open a copy in the AppleScript Editor, and place your table editing statements where indicated in the script. Enjoy!
IMPORTANT TIP: Learn how to save and run your favorite scripts using the system-wide Script Menu.
Identifying Selected Table
01
tellapplication "Keynote"
02
activate
03
try
04
if not (existsdocument 1) then errornumber 1000
05
telldocument 1
06
try
07
tellcurrent slide
08
set theselectedTableto ¬
09
(the firsttablewhoseclassofselection rangeisrange)
10
end tell
11
on error
12
errornumber 1001
13
end try
14
tellselectedTable
15
-- editing statements go here
16
end tell
17
end tell
18
on errorerrorMessagenumbererrorNumber
19
iferrorNumberis 1000 then
20
setalertStringto "MISSING RESOURCE"
21
seterrorMessageto ¬
22
"Please create or open a document before running this script."
23
else iferrorNumberis 1001 then
24
setalertStringto "SELECTION ERROR"
25
seterrorMessageto "Please select a table before running this script."
Mention of third-party websites and products is for informational purposes only and constitutes neither an endorsement nor a recommendation. MACOSXAUTOMATION.COM assumes no responsibility with regard to the selection, performance or use of information or products found at third-party websites. MACOSXAUTOMATION.COM provides this only as a convenience to our users. MACOSXAUTOMATION.COM has not tested the information found on these sites and makes no representations regarding its accuracy or reliability. There are risks inherent in the use of any information or products found on the Internet, and MACOSXAUTOMATION.COM assumes no responsibility in this regard. Please understand that a third-party site is independent from MACOSXAUTOMATION.COM and that MACOSXAUTOMATION.COM has no control over the content on that website. Please contact the vendor for additional information.