Reading an image path from Indesign

Hello,

I was wondering if someone could lend me a hand with this; I’m trying to extract an image path from a graphic in a rectangle in an Indesign document.

This works:

tell application "Adobe InDesign CS3"
	set imagepath to file path of item link of selection
end tell

However, this doesn’t:

tell application "Adobe InDesign CS3"
	set imagepath to file path of item link of rectangle 1
end tell

What I’d like to do is to be able to read the file path from a specific box (which I have labeled using the script label property)

What am I doing wrong? It worked fine with reading a text frame.

Any help would be very appreciated

Hello,

Rectangle 1 is the first rectangle, not a reference to a labeled frame, and I suspect it’s not your intended target. Could you mean rectangle “1”?

Aye, I tried setting the rectangle up with the “ProductPhoto” label, and reading it thusly:

tell application "Adobe InDesign CS3"
   set imagepath to file path of item link of rectangle "ProductPhoto"
end tell

But Applescript returns the following:

Adobe InDesign CS3 got an error: Can’t get file path of item link of rectangle “ProductPhoto”

You are missing a few parts to your set statement:

set imagepath to file path of item link of item 1 of all graphics of rectangle 1

The rectangle contains a property all graphics, this is a list of all images placed in it. Since you have one image placed in the rectangle you use item 1 of the list. This has the property item link, which in turn has the file path.