I still fight this error in Indesign CS4, 5. The code below works as expected:
set ax to "server:logos:mylogofile.pdf"
tell application "Adobe Indesign CS5"
tell document 1
tell document 1
set thisRect to object reference of selection
tell thisRect
place (ax as alias)
fit thisRect given proportionally --this works
end tell --ax
end tell
end tell --doc 1
end tell --app
This same snippet fails in context of a much more complex script where I pull from a database, find the named label of an image frame and place the designated image onto it as above.
I’ve used the same context for my scrap/test ID document for that image and the only difference is the script. OK, I won’t dump the script, which has lots of routines to find the right data snippet to the right frame.
But here is where I do want help. Looking at the Event log history, the failure occurs:
In the snippet above:
I’ve given up hunting for the meaning of -1708, and am trying to see why the two references to the frame don’t line up. That’s my only clue, but I don’t know how to attack it. If you were me, what else should I attempt? thanx, sam
there are a few reference confusions.
Normally the objects in selection include full references,
so the (double ?!) document tell block is not needed at all.
set ax to "server:logos:mylogofile.pdf"
tell application "Adobe InDesign CS5"
set thisRect to object reference of selection
tell thisRect
place (ax as alias)
fit it given proportionally
end tell --ax
end tell --app
Thank you Stefan for responding swiftly. The change still failed but it makes me think that the reference to the rectangle is missing something that selection has.
So let’s open up the context a little on the portion that is affecting this failed code.
tell application "Adobe Indesign CS5"
tell document 1
--lots of code to process database and find the image fields
repeat with i from 1 to imgFieldCt
set allRect to (every rectangle of every story whose label is (item i of imgField as text))
if (count of allRectangles) > 0 then
repeat with thisRect in allRect
set thisRectObj to object reference of thisRect
tell thisRect
set ax to item thisImgTextFrame of imgValue
set fitting alignment of frame fitting options to bottom left anchor
try
place ax as alias
fit it given proportionally
end try
end tell
end repeat
end if
end repeat
end tell --document
end tell -- app
The fact that this rectangle is embedded in a text frame should not distract. This same frame, in this context, works with the small snippet posted earlier. It’s just within this context it fails.
As you’ll see, I’m using the results of hunting for the labels matching the field name to make an object reference to the rectangle. I’m unsure how I can be more specific or to get a more “complete” object reference so that the fit works as expected? thanx, sam