mingsai

Numbers Identifying Selected Table

Feb 22nd, 2014
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. tell application "Numbers"
  2.     activate
  3.     try
  4.         if not (exists document 1) then error number 1000
  5.         tell document 1
  6.             try
  7.                 tell active sheet
  8.                     set the selectedTable to ¬
  9.                         (the first table whose class of selection range is range)
  10.                 end tell
  11.             on error
  12.                 error number 1001
  13.             end try
  14.             tell selectedTable
  15.                 -- editing statements go here
  16.             end tell
  17.         end tell
  18.     on error errorMessage number errorNumber
  19.         if errorNumber is 1000 then
  20.             set alertString to "MISSING RESOURCE"
  21.             set errorMessage to "Please create or open a document before running this script."
  22.         else if errorNumber is 1001 then
  23.             set alertString to "SELECTION ERROR"
  24.             set errorMessage to "Please select a table before running this script."
  25.         else
  26.             set alertString to "EXECUTION ERROR"
  27.         end if
  28.         if errorNumber is not -128 then
  29.             display alert alertString message errorMessage buttons {"Cancel"}
  30.         end if
  31.         error number -128
  32.     end try
  33. end tell
Advertisement
Add Comment
Please, Sign In to add comment