InDesign CS5 relink syntax error


Going from CS3 to CS5 it appears that the relink syntax I’ve been using is no longer valid.

To focus on the syntax itself, I’m using an example StephanK posted, a document with only one link (broken), and the replacement path hard-coded, CS3 changed to CS5:

tell application "Adobe InDesign CS5"
	set usedGraphics to links of active document
	repeat with i from 1 to count items in usedGraphics
		set currentGraphic to item i of usedGraphics
		set newpath to "design:Links:Printer_ColorCorrect:2008_2011:42-15117694.tif" -- a string file name
			relink currentGraphic to newpath
		end try
	end repeat
end tell

-- started
tell application "Adobe InDesign CS5"
	get every link of active document
	-->		{link id 207 of image id 203 of rectangle id 208 of spread id 186 of document id 20
	relink link id 207 of image id 203 of rectangle id 208 of spread id 186 of document id 20 to "design:Links:Printer_ColorCorrect:2008_2011:42-15117694.tif"
	-->	error "Cannot create the link resource from the given URI."number 35869
end tell
-- stopped

Just to be clear, the replacement link does exist:

-- started
choose file
-->	alias "design:Links:Printer_ColorCorrect:2008_2011:42-15211694.tif"
-- stopped

I’d appreciate any help.



have you tried:
tell app “Finder” to set newpath to (newpath as alias)
relink currentGraphic to newpath
relink currentGraphic to file newpath

The coercion to “file” did the trick.

		relink currentGraphic to file newpath

Thanks a bunch!

Technically, “file” is a specifier. It describes the object type given in your string path. That’s not the same thing as coercion, which changes one type to another. This may seem like a nitpick, but it’s helpful to understanding why it was needed at all. A literal string can’t be converted to a file.