Numbers won't load file directed by AppleScript
I am trying to get around the flaw in Number's that won't allow links to external files. I presently have to cut and paste 20 files a day into a spreadsheet and would like to automate the process. I have tried utilizing code that I have found on the web but I can't seem to get it to work. I am not a software guy and a am a newbie to this. The problem is that the Numbers app cant open the input file as directed by the AppleScript code.
I keep getting the following error:
error "Numbers got an error: Can’t get document \"/Users/bill/Documents/test.csv\"." number -1728 from document "/Users/bill/Documents/test.csv"
The path is definitely correct and I have tried running the code with the files already open. Any help would be appreciated. I don't want to have to buy Excel.
The code is as follows:
set theDefaultFolder to POSIX file "/Users/billseton/Documents"
property src : {d:"/Users/bill/Documents/test.csv", s:"Sheet 1", t:"Source"}
property tgt : {d:"/Users/bill/Documents/DailyBuys.numbers", s:"Sheet 1", t:"Target"}
tell application "Numbers"
--vList is a "list of lists" - a two-dimensional array
set vList to document (src's d)'s sheet (src's s)'s table (src's t)'s rows's cells's value
tell document (tgt's d)'s sheet (tgt's s)'s table (tgt's t)
repeat with r from 1 to count rows
repeat with c from 1 to count columns
set row r's cell c's value to vList's item r's item c
end repeat
end repeat
end tell
end tell
iMac 21.5″, macOS 12.7