Error while running Annotate on Quark pages

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
		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

I just ran it on a document with 75 pages, 3 images per page and all was OK. (6.5 on 10.3.9).

A crazy idea might be to try to comment out the set properties line (font & size, or at least the font) and see what you get. I’m thinking this may be somehow related to the occasionally screwy font handling in Quark.


Thank you nedloh99 for your answer, but after much experimentation, I don’t think that it is a font problem.

Our department is moving toward having pages built to trim size, with bleeds pulled out beyond trim. Previously, we built our spreads with non-printing area beyond the bleed and trim, and Annotate worked.

The workaround that I have found involves pulling the left bleed on the left-hand page in to the page trim.

Obviously, as before, you have to make a copy of the Quark file first, since multiple type boxes will be added.

I am still not sure why Annotate script doesn’t like picture boxes beyond the left-edge trim, but this workaround works.

Now, if I can figure out why the Annotate script still sometimes puts in multiple type boxes (sometimes as many as 25 ! ) for the same picture box !

–Herbert Ripka
Greendale, WI