When running the following AppleScript, I get the following message from the Event Log: “QuarkXPress got an error: Can’t set properties of story 1 of text box "annotate1" of page 6 of document 1 to {font:"Times", size:12}.” Why?
This AppleScript works great initially, then errors out on later pages of multi-page documents. This script places the picture name of each picture box in a new type box in the upper left corner of that picture box. Re-launching Quark and AppleScript doesn’t solve the problem. I run AppleScript 1.9.3, Mac OSX 10.3.7, and Quark 6.5.
Thank you for any help in solving this problem.
–Herbert Ripka
Greendale, WI
set otp to 0
set olft to 0
set filename to 0
set sc1 to 0
set sc2 to 0
tell application "QuarkXPress"
if (document 1 exists) then
tell document 1
set properties to {horizontal measure:points, vertical measure:points}
repeat with p from 1 to (count of pages)
tell page p
repeat with i from 1 to (count of picture boxes in it)
if not (count of images in picture box i) = 0 then
tell picture box i
if not (bounds of image 1) = {0, 0, 0, 0} then
set name of it to "p" & p & "picbox" & i
set filevar to file path of image 1 of it as text
set filename to my getfileName(filevar)
copy (scale of image 1 of it as list) to {sc1, sc2}
copy (origin of bounds of it as list) to {otp, olft}
end if
end tell
make text box at beginning with properties {bounds:{otp, olft, ((otp as real) + 14), ((olft as real) + 175)}, color:"yellow", name:"annotate" & i, runaround:none runaround}
tell (story 1 of text box ("annotate" & i))
set properties to {font:"Times", size:12}
set contents of it to ("" & filename & " " & (sc1 as text))
end tell
end if
end repeat
end tell
end repeat
end tell
else
display dialog "Must have document with graphics open for this script to work"
end if
end tell
on getfileName(path)
set pathstr to (path as string)
set lastColon to (offset of ":" in (reverse of (characters of pathstr)) as string) of pathstr
return text from -(lastColon - 1) to -1 of pathstr
end getfileName