• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Make script work on current page AS

Community Beginner ,
Feb 25, 2009 Feb 25, 2009

Copy link to clipboard

Copied

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.
TOPICS
Scripting

Views

343

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Feb 25, 2009 Feb 25, 2009

Copy link to clipboard

Copied

Try:<br /><br />set linkTextFrame to make text frame at beginning of active page of layout<br />window 1<br /><br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Sessions <a href=http://scriptingmatters.com/aspro>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 26, 2009 Feb 26, 2009

Copy link to clipboard

Copied

LATEST
Shane,
Thank you so much for the prompt reply. It worked after I took out the word "layout" (AppleScript saw it as a variable) and made some similar tweaks later in the script.
It sure can be aggravating to spend hours trying to figure out something that turns out to be so simple. Thank goodness for these forums and thanks again to you.
Mike D.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines