read/write permissions failing for a folder created by apple script

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"


I don’t own Word so I can’t test but I assume that this cleaned script may do what is wanted.

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 # EDITED
set monthname to month of d # EDITED
--dayname & monthname as string # useless
set the_date to dayname & monthname # EDITED

set jointFolder to (path to home folder as text) & "Dropbox:lbc services joint folder"
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
	set dateFolder to (make new folder at folder jointFolder with properties {name:the_date}) as text # EDITED
	--end tell
	
	
	tell me to 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
	set datePMFolder to (make new folder at folder jointFolder with properties {name:the_date & pm}) as text # EDITED
	--close Finder window 1 # useless
end tell
say "I have created both folders as requested"


set mydoc to POSIX path of (jointFolder & "Service Running Schedule - DO NOT DELETE!.dotx")
set newDoc1 to POSIX path of (dateFolder & "Service running schedule am1.docx")
set newDoc2 to POSIX path of (dateFolder & "Service running schedule am2.docx")
set newDoc3 to POSIX path of (datePMFolder & "Service running schedule.docx")

# I stopped testing here

tell application "Microsoft Word"
   activate
   open mydoc
   save as active document file name newDoc1
   save as active document file name newDoc2
   save as active document file name newDoc3
   close active document
end tell

say "That is the files done too, closing down"

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) lundi 2 janvier 2017 15:26:27

Hi. Welcome to MacScripter.

Not related to your problem, but if Yvan’s modifications do the trick, another refinement would be this at the top of the script instead of the repeat:

set d to (current date)
set w to (weekday of d) as number
if (w > 1) then set d to d + (8 - w) * days
d