AppleScript in Numbers, How to Copy Rows and Columns from one document to another
Applescript Newb here but after a couple days of studying I'm not making much progress. Hoping the community can help.
I'm trying to copy the following from the first document: 1 column from 1 sheet always, 1 row from one sheet always, and 0 to 10 rows each from 2 additional sheets, all in the same document. These columns and rows won't change, only how many rows of info the last two sheets may change. For a work flow method at a tree service I copy the same Numbers template file for each new tree care job. But the job will have different properties. Sometimes it's just a dead tree removal. Sometimes just a stump removal. Sometimes it's both. I have dozens of columns with data entry. I use the Forms function on the iPad to create a new 'file from template' for each tree job. I'm sure there's a better way, but for now at my technological skill level this is what I'm trying. So after each Numbers file is complete, I open it via the cloud on the desktop and then I manually copy the 4 to 20 or so lines into the master file, where I perform further data analysis, refine future time estimates, etc. So I'm trying to save time by automating this row and column copying process.
The destination file will remain the same for a certain amount of time, maybe a month. So for now I'd like to keep the option of choosing the destination file. (Later I envision switching to an Automator Application where I would drag each of the new job files onto the App to have it perform the work, to a single destination file.)
Source File simplified examples:
Destination File simplified Examples. The new rows/columns are added below/beside.
So you can see I would want the copied rows to go below the previous rows on three of the sheets, and the copied columns to go to the right of the previous columns on the Test Logbook Sheet.
Here is the Applesript code I've stumpled through from reading online, but it is not very close to the solution I think.
set file_1 to choose file of type "numbers" with prompt "Choose the Job file"
set file_Destination to choose file of type "numbers" with prompt "Choose Destination file"
tell application "Numbers"
set document_1 to open file_1 -- that is, copy file's contents from disk to RAM of Numbers.app
set tblName1 to "Table 1"
set srceRng to "4"
end tell
tell application "Numbers"
set document_2 to open file_Destination
set tblName2 to "Table 1"
set destRng to "7"
tell document 1 to tell active sheet
tell table tblName2
set destRow to range destRng's row 1's address
repeat with c in range srceRng's cells
set v to c's value
set r to c's column's address
set column r's cell destRow's value to v
end repeat
end tell
end tell
end tell
Thanks very much for any help!
Mac Pro