Hey Folks,
Make a selection anywhere in a row.
Run the script and extract the values of cells in columns A, B, & C of the selected row to Keyboard Maestro variables.
------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2017/02/07 18:15
# dMod: 2017/02/12 18:54
# Appl: Numbers
# Task: Extract Data from the selected row of the front spreadsheet and enter into KM variables.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Numbers, @Extract, @Data, @Numbers, @Spreadsheet, @Keyboard_Maestro
------------------------------------------------------------------------------
tell application "Numbers"
tell document 1
tell active sheet
---------------------------------------------------------------------
# Ensure there IS a selection:
---------------------------------------------------------------------
try
set activeTable to (the first table whose class of selection range is range)
on error
error "Something is wrong with the selection in the front document."
end try
---------------------------------------------------------------------
# Data Extraction
---------------------------------------------------------------------
tell activeTable
set rowList to rows of selection range
set theRow to item 1 of rowList
set rowNum to (address of theRow) as text
set orderID to formatted value of first cell of range ("A" & rowNum)
set purchaseDate to formatted value of first cell of range ("B" & rowNum)
set purchaseName to formatted value of first cell of range ("C" & rowNum)
end tell
---------------------------------------------------------------------
end tell
end tell
end tell
------------------------------------------------------------------------------
# Enter data into Keyboard Maestro variables.
------------------------------------------------------------------------------
tell application "Keyboard Maestro Engine"
setvariable "orderID" to orderID
setvariable "purchaseDate" to purchaseDate
setvariable "purchaseName" to purchaseName
end tell
------------------------------------------------------------------------------
-Chris