duplicate a document in Numbers using Applescript
Hi,
I'm trying to process a series of Numbers documents and copy some of their content into a few version of the document. I can't seem to get the duplication command to work because I can't get the "to location-specifier" phrase to accept a location. I've tried quite a few variation but here's the current version of the program skeleton. I'm showing two different variations I've tried to create a proper "location-specifier". I'm assuming this wants a directory but I've also tried creating a directory/filename as well.
The error I get is "Script Error -- Numbers got an error: Can't make alias "Macintosh HD:Users:username:Desktop:" into type location specifier.
I've tried the first version (the one that's currently commented out) with it ending with "as alias", "as string", "as alias as string", and with nothing after the closing ")". None of those options work. I've also tried having the Finder application executate that command but that doesn't work either.
tell application "Numbers"
activate
set templateDoc to open "/Users/username/Desktop/TestDirectory/Template5.numbers"
tell application "Finder" to set flist to files of folder (POSIX file "/Users/username/Desktop/TestDirectory/WeeklySalesSheets/") as alias list
-- Here's where I try to create the directory to use in the "to location-specifier" phrase of the duplicate command
-- I'm showing two different things I've tried -- and I've tried many other variations.
--set destDir to (POSIX file "/Users/username/Desktop/TestDirectory/WeeklySalesSheets/") as alias
set destDir to (path todesktop)
repeat with fn in flist
set srcDoc to openfn
set destDoc to duplicatetemplateDoctodestDir -- This is the line that fails
set destDoc'sname to (name of fn & " Update")
-- transfer data from srcDoc to destDoc
closesrcDoc
closedestDoc
end repeat
end tell
Thanks,
Dave
Numbers 3.5.2-OTHER, OS X Yosemite (10.10.1)