With which main file are you starting ?
I never use Merdosoft products so I’m not sure that you use an Excel file.
As far as I know, in such file we can’t have several tables in a sheet so we can’t have a table named “table1_2” and a table named “table1_6” in the sheet named “sheet1”.
Are you sure that you use the names of items used in my script.
I carefully named the sheets “sheet1” and “sheet3” and named the tables as “table1-1”, “table1-2”, “table1-6”, “table3-1”.
The described error message let me think that in your file the first sheet is not named “sheet1”.
Below is an enhanced version which compute the number of rows imported from a people without using the table “fake”.
script o
# These properties will be visible from the handler but will not be saved on disk
property peopleNames : {}
property targetName : missing value
end script
set path2Target to (path to desktop as text) & "mainDocument.numbers" # Edit to fit your needs
set folder4peoples to (path to desktop as text) & "peoples" # Edit to fit you needs
tell application "Finder"
set peopleFiles to every file of folder folder4peoples as alias list
end tell
# Now we have a list of the available people files
# The main document is supposed to be
tell application "Numbers"
open path2Target as «class furl»
set o's targetName to name of document 1
set o's peopleNames to {}
repeat with aPeopleFile in peopleFiles
set aPeopleDoc to open aPeopleFile
set end of o's peopleNames to name of aPeopleDoc
end repeat
end tell
# Now we have a list of the available people documents
# I'm not sure that the upper row to import is the same in every tables
# So I define several ones.
set upper1_1 to 2
set upper1_2 to 2
set upper1_6 to 2
set upper3_1 to 2
set upperInMain to 2
set rowsFilled to 0
repeat with aPeopleName in o's peopleNames # Edit sheets and tables names to fit your needs.
set rowsCnt to my importFrom(aPeopleName, "sheet1", "table1-1", {"B", "I", "K"}, upper1_1, upperInMain, 0)
set rowsCnt to my importFrom(aPeopleName, "sheet1", "table1-2", {"A", "B", "C", "D", "E"}, upper1_2, upperInMain, rowsCnt)
set rowsCnt to my importFrom(aPeopleName, "sheet1", "table1-6", "A", upper1_6, upperInMain, rowsCnt) # I deliberately missed the brackets
set rowsCnt to my importFrom(aPeopleName, "sheet3", "table3-1", {"A", "F"}, upper3_1, upperInMain, rowsCnt)
set rowsFilled to rowsFilled + rowsCnt
set upperInMain to upperInMain + rowsFilled
# So datas from the next people will be pasted starting from the same row in every table.
end repeat
on importFrom(aPeopleName, sheetName, tableName, theColumns, higherRowInPeople, higherRowInTarget, maxnumber)
# Take care of possible omission of brackets when there is a single column to treat
if class of theColumns is not list then set theColumns to {theColumns}
set windowMenu to 11 # Index of the menu "Window"
copy higherRowInTarget to upperRow
tell application "Numbers"
repeat with c from 1 to count theColumns
set aColumn to (item c of theColumns) as text
tell document aPeopleName
tell sheet sheetName to tell table tableName
tell column aColumn
repeat with i from (count rows) to 1 by -1
if value of cell i is not missing value then exit repeat
end repeat
set theRange to (name of cell higherRowInPeople) & ":" & (name of cell i)
end tell
set maybe to i - higherRowInPeople + 1
if (maybe > maxnumber) then set maxnumber to maybe
set selection range to range theRange
end tell # sheet.
end tell # document
tell application "System Events" to tell process "Numbers"
set frontmost to true
tell menu bar 1 to tell menu bar item windowMenu to tell menu 1 to click menu item aPeopleName # brings the people window to front
keystroke "c" using {command down}
end tell
# the clipboard contains the datas from the people
tell document (o's targetName) to tell sheet sheetName to tell table tableName
if (upperRow > (count rows)) then
repeat (upperRow - (count rows)) times
add row below last row
end repeat
end if
set selection range to range (name of cell upperRow of column aColumn)
end tell
tell application "System Events" to tell process "Numbers"
tell menu bar 1 to tell menu bar item windowMenu to tell menu 1 to click menu item (o's targetName) # brings the main window to front
keystroke "v" using {command down}
end tell
end repeat
return maxnumber
end tell # Numbers
end importFrom
You may download the script and the documents used to test it at :
https://app.box.com/s/seq9ofwvkkmfyiugjtzw71axxhare8t1
From my point of view, if you want to choose the main file it would be safer to use :
set path2Target to choose file with prompt "Please select today's Master:" of type {"com.apple.iwork.numbers.numbers", "com.apple.iwork.numbers.sffnumbers"}
Yvan KOENIG running Sierra 10.12.4 in French (VALLAURIS, France) lundi 10 avril 2017 18:47:18