Editing existing tables usually requires the initial step of identifying the table(s) to be edited. A script can search every sheet 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!
Identifying Selected Table
if not (existsdocument 1) then errornumber 1000
set theselectedTableto ¬
(the firsttablewhoseclassofselection rangeisrange)
-- editing statements go here
iferrorNumberis 1000 then
setalertStringto "MISSING RESOURCE"
"Please create or open a document before running this script."
else iferrorNumberis 1001 then
setalertStringto "SELECTION ERROR"
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.