I've made the following script for adding a text object with the name of a linked item, but it only works when the item is on the first page of the document:
tell application "Adobe InDesign CS3"
tell document 1
try
set linkName to (name of item link of all graphics of item 1 of selection)
on error
display dialog "Select a linked item to add its name." buttons {"Cancel"} default button 1
end try
set linkID to id of selection
set geoBounds to geometric bounds of selection
set nameYpos to ((item 3 of geoBounds) + 0.0625) as real
set fullNameCount to number of characters of linkName
set nameCount to (fullNameCount - 4)
set linkNameNoSuffix to (characters 1 thru nameCount) of linkName as string
set linkTextFrame to make text frame
set avgXpos to ((item 4 of geoBounds) + (item 2 of geoBounds)) * 0.5
if ((item 4 of geoBounds) - (item 2 of geoBounds)) < 2 then
set geometric bounds of linkTextFrame to {nameYpos, avgXpos - 1, nameYpos + 0.25, avgXpos + 1}
else
set geometric bounds of linkTextFrame to {nameYpos, (item 2 of geoBounds), nameYpos + 0.25, (item 4 of geoBounds)}
end if
set contents of linkTextFrame to linkNameNoSuffix
tell text frame 1
tell paragraph 1
set justification to center align
set point size to 10
end tell
end tell
set linkTextID to id of linkTextFrame
set selection to {}
set linkGroup to make group with properties {group items:{text frame id linkTextID, rectangle id linkID}}
activate
end tell
end tell
Can anyone tell me how to get it to work on whatever page the selected linked item is on? Thanks in advance.
Mike D.