Excel error in Applescript
I have been using a script to compile data from monthly reports to an annual report. Recently one of the scripts has been returning a "file already open" warning. This only happens when I run the script for this location. I use similar scripts for different locations and they run fine. I don't know why this one suddenly quit working. I have tried copying and modifying the working scripts but get the same open file warning. I understand some of the script but not all of it. I had help putting it together and i'm hoping another set of eyes can help me out. The script opens the annual report and compiles the info from the other files, then saves the report and files the monthly reports in their respective month. Any suggestions would be greatly appreciated.
property total_student : 1
tell application "Finder"
set master_path to alias "users:fac:Desktop:Temple Annual Reports:DWI Annual Report:DWI Report.xlsx"
set filesWithDWI to get every file of folder ((path to desktop folder) & "Temple Annual Reports:DWI Annual Report" as string) whose name contains "DWI"
repeat with f in filesWithDWI
my transfer_data(f, master_path)
end repeat
end tell
on transfer_data(child_path, master_path)
tell application "Microsoft Excel"
set child_book to (open workbook workbook file name (child_path as string))
set child_doc to worksheet 1 of child_book
set master to worksheet "Sheet1" of (open workbook workbook file name (master_path as string))
set num to 14 --All lists start at index 12 or later, I'm putting 10 to be safe
set students to {}
tell child_doc --grab values from child document
repeat until (value of cell (("A" & num) as string)) is 1
set num to num + 1
end repeat
repeat until (value of cell (("B" & num) as string)) is ""
set end of students to {name:(value of cell (("B" & num) as string)), driver_id:(value of cell (("C" & num) as string)), DOB:(value of cell (("D" & num) as string)), pre_test:(value of cell (("J" & num) as string)), post_test:(value of cell (("K" & num) as string)), cert_id:(value of cell (("L" & num) as string)), NDP:(value of cell (("J" & num) as string))}
set num to num + 1
end repeat
set startdate to range "C6"
set classlocation to range "C10"
set instructor to range "I7"
end tell
tell master
set num to 7
log (value of cell (("B" & num) as string))
repeat until (value of cell (("B" & num) as string)) is ""
set num to num + 1
end repeat
repeat with student in students
set value of cell (("A" & num) as string) to total_student
set value of cell (("B" & num) as string) to name of student
set value of cell (("C" & num) as string) to driver_id of student
set value of cell (("D" & num) as string) to DOB of student
set value of cell (("E" & num) as string) to classlocation
set value of cell (("f" & num) as string) to startdate
set value of cell (("G" & num) as string) to instructor
set value of cell (("H" & num) as string) to pre_test of student
set value of cell (("I" & num) as string) to post_test of student
set value of cell (("J" & num) as string) to cert_id of student
set value of cell (("k" & num) as string) to NDP of student
set num to num + 1
set total_student to total_student + 1
end repeat
end tell
save child_book
close child_book
save active workbook in master_path
close active workbook
end tell
end transfer_data
do shell script "
for f in \"$HOME/Desktop/Temple Annual Reports/DWI Annual Report/\"*
do
if [ ! -d \"$f\" ]; then
x=\"${f%%.*}\"
i=$((${#x}-3))
if [ -d \"$HOME/Desktop/Temple Monthly Reports/DWI Monthly/${f:$i:3}\" ]; then
mv \"$f\" \"$HOME/Desktop/Temple Monthly Reports/DWI monthly/${f:$i:3}\"
fi
fi
done"
MacBook Pro (13-inch Mid 2012), OS X El Capitan (10.11.4)