I just discover your messages.
Thanks for the feedback.
I never used password protected Numbers document so I let you treat the problem.
Below is an alternate version.
For each treated table, it copy paste in a single action the cells from every columns starting from the first one defined in the caller instruction.
On my side I see no difference in the final result but it’s REALLY FASTER.
(*
master merge alt.scpt
written for http://macscripter.net/viewtopic.php?id=45652
Consolidate datas from several Numbers documents in a single one.
This alternate version copy paste every columns of the 4 tables.
KOENIG Yvan, (VALLAURIS, France)
2017/04/12
*)
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
property transferHeaders : false
# true = transfer the row headers
# false = doesn't transfer the row headers
property twoSpaces : space & space
property threeSpaces : space & space & space
property windowMenu : 11 # Index of the menu "Window"
set path2Target to choose file with prompt "Please select today's Master:" of type {"com.apple.iwork.numbers.numbers", "com.apple.iwork.numbers.sffnumbers"} # Edit to fit your needs
set folder4peoples to (path to desktop as text) & "Daily Sheets" # 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 id "com.apple.iwork.numbers"
open path2Target # it's an alias
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
# params for tables from sheet Watch List
set upper1_1 to 2
set upper1_2 to 2
set upper1_6 to 2
set upperInMain to 2
# params for table from sheet PASTE HERE
set upper3_1 to 1 # CAUTION, there is no header row in the table PASTE HERE !
set upperInMain3 to 1
set filledInWatchList to upperInMain
set filledInScheduledCallbacks to upperInMain
set filledInVoicemailTracker to upperInMain
set filledInPASTEHERE to upperInMain3
repeat with aPeopleName in o's peopleNames # Edit sheets and tables names to fit your needs.
set rowsInWatchList to 0
set rowsInScheduledCallbacks to 0
set rowsInVoicemailTracker to 0
set rowsInPASTEHERE to 0
#----- treat table Watch List
set rowsInWatchList to my importFrom(aPeopleName, "Watch List", "Watch List", {"B", "N"}, upper1_1, filledInWatchList) # Pass the starting column (here "B")
set filledInWatchList to filledInWatchList + rowsInWatchList - 1 # don't repeat the header row
#----- treat table Scheduled Callbacks
set rowsInScheduledCallbacks to my importFrom(aPeopleName, "Watch List", "Scheduled Callbacks", {"A", "M"}, upper1_2, filledInScheduledCallbacks)
set filledInScheduledCallbacks to filledInScheduledCallbacks + rowsInScheduledCallbacks - 1 # don't repeat the header row
#----- treat table Voicemail Tracker
set rowsInVoicemailTracker to my importFrom(aPeopleName, "Watch List", "Voicemail Tracker", {"A", "E"}, upper1_6, filledInVoicemailTracker)
set filledInVoicemailTracker to filledInVoicemailTracker + rowsInVoicemailTracker - 1 # don't repeat the header row
#----- treat table PASTE HERE
set rowsInPASTEHERE to my importFrom(aPeopleName, "PASTE HERE", "PASTE HERE", {"A", "F"}, upper3_1, filledInPASTEHERE)
set filledInPASTEHERE to filledInPASTEHERE + rowsInPASTEHERE # no header row in PASTE HERE
end repeat
display notification "The Master Has Been Merged!" with title "Thanks For Using Master Merger!" sound name "Glass.aiff"
#=====
on importFrom(aPeopleName, sheetName, tableName, theColumns, higherRowInPeople, higherRowInTarget)
local i, theRange
# transfer every columns starting from (theColumns's item 1)
tell application id "com.apple.iwork.numbers"
tell document aPeopleName to tell sheet sheetName to tell table tableName
tell column (theColumns's item 1)
repeat with i from 1 to (count rows)
if value of cell i is in {missing value, "", space, twoSpaces, threeSpaces} then exit repeat
end repeat
end tell
copy i to maxNumber
set theRange to (name of cell higherRowInPeople of column (theColumns's item 1) & ":" & (name of cell (maxNumber) of column (theColumns's item 2)))
set selection range to range theRange
end tell # document
end tell # Numbers
tell application "System Events" to tell process "Numbers"
set frontmost to true # REQUIRED
tell menu bar 1 to tell menu bar item windowMenu to tell menu 1 to click menu item aPeopleName # brings the source window to front
keystroke "c" using {command down}
end tell
tell application id "com.apple.iwork.numbers"
# the clipboard contains the datas from a people
tell document (o's targetName) to tell sheet sheetName to tell table tableName
if (higherRowInTarget > (count rows)) then
repeat (higherRowInTarget - (count rows)) times
add row below last row
end repeat
end if
set theRange to (name of cell higherRowInTarget of column (theColumns's item 1))
set selection range to range theRange
end tell
end tell # Numbers
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 target window to front
keystroke "v" using {command down, option down, shift down} # paste applying the style defined in the receiver
end tell
return maxNumber
end importFrom
#=====
Is it really useful to keep thousands of rows in the table “PASTE HERE” ?
Yvan KOENIG running Sierra 10.12.4 in French (VALLAURIS, France) mercredi 12 avril 2017 11:18:30