The following has worked, something changed on my macbook and now it doesn’t anymore. Any help would be appreciated.
The script creates two folders with next Sunday’s date, opens a MSWord template and saves a copy in each folder. Supposedly! It appears to be something to do with apple script not having the permissions to create the new files in the folders it has just created. If I run the program live (whilst I am sitting watching it) it asks me to grant permission for the folder access.
set d to current date
repeat
set w to (weekday of d) as number
if w = 1 then exit repeat
set d to d + (1 * days)
end repeat
d
set dayname to {day} of d as string
set monthname to {month} of d
dayname & monthname as string
set the_date to dayname & monthname as string
tell application "Finder"
activate
open home
set target of Finder window 1 to folder "lbc services joint folder" of folder "Dropbox" of folder "Iona" of folder "Users" of startup disk
make new folder at folder "lbc services joint folder" of folder "Dropbox" of folder "Iona" of folder "Users" of startup disk with properties {name:dayname & monthname}
end tell
say "done first one"
set pm to "PM"
tell application "Finder"
activate
set target of Finder window 1 to folder "lbc services joint folder" of folder "Dropbox" of folder "Iona" of folder "Users" of startup disk
make new folder at folder "lbc services joint folder" of folder "Dropbox" of folder "Iona" of folder "Users" of startup disk with properties {name:dayname & monthname & pm}
close Finder window 1
end tell
say "I have created both folders as requested"
set mydoc to "/Users/iona/Dropbox/lbc services joint folder/Service Running Schedule - DO NOT DELETE!.dotx"
tell application "Microsoft Word"
activate
open mydoc
save as active document file name "/Users/iona/Dropbox/lbc services joint folder/" & the_date & "/Service running schedule am1.docx"
close active document
end tell
set mydoc to "/Users/iona/Dropbox/lbc services joint folder/Service Running Schedule - DO NOT DELETE!.dotx"
tell application "Microsoft Word"
activate
open mydoc
save as active document file name "/Users/iona/Dropbox/lbc services joint folder/" & the_date & "/Service running schedule am2.docx"
close active document
end tell
set mydoc to "/Users/iona/Dropbox/lbc services joint folder/Service Running Schedule - DO NOT DELETE!.dotx"
tell application "Microsoft Word"
activate
open mydoc
save as active document file name "/Users/iona/Dropbox/lbc services joint folder/" & the_date & "pm/Service running schedule.docx"
close active document
end tell
say "That is the files done too, closing down"