Reputation: 45
New to AppleScript but I'm working on a script that takes a folder of images, gets the name, color profile, width, height, and calculates the aspect ratio (WxH) of each image and exports all that information to an excel file. I was able to do this successfully when simply writing to a .csv but now I actually want to write to a .xls so I can also do some conditional formatting to the aspect ratio column. Below is the block of code causing trouble. When I go to compile I get the following error:
AppleScript Compile Error:
Can’t set «class DPVu» of «class ccel» "A" & num to imgName. Access not allowed.
This error occurs on the first "set value of cell" statement. If I comment each of these lines one at a time and compile, it throws the same error for each of them.
I've tried googling everything I can think to google and have found nothing helpful...
Code:
--counter variable for excel row placement. (row 1 is a header row)
set num to 2
repeat with img in imgFolder
--write specs to excel file
tell application "Microsoft Excel"
set value of Cell "A"&num to imgName
set value of Cell "B"&num to imgColorProfile
set value of Cell "C"&num to imgWidth
set value of Cell "D"&num to imgHeight
set value of Cell "E"&num to imgRatio
end tell
--incremental counter for next excel row
set num to num + 1
end repeat
Upvotes: 2
Views: 1541
Reputation: 285260
I would write simpler
set num to 2
repeat with img in imgFolder
--write specs to excel file
tell application "Microsoft Excel"
tell row num
set value of cell 1 to imgName
set value of cell 2 to imgColorProfile
set value of cell 3 to imgWidth
set value of cell 4 to imgHeight
set value of cell 5 to imgRatio
end tell
end tell
--incremental counter for next excel row
set num to num + 1
end repeat
Upvotes: 0