🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #924

Make script work on current page AS

#924
From: Michael_H._Davenport
Date: Thu, 26 Feb 2009 00:22
22 lines
2208 bytes
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.
Technical Details
Message-ID: <59b80d78.-1@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!newshub.sdsu.edu!webcrossing

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,9e567a3496cce17,start
X-Google-Attributes: gidf939a,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: Michael_H._Davenport@adobeforums.com
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!newshub.sdsu.edu!webcrossing
Newsgroups: adobe.scripting.indesign
Subject: Make script work on current page AS
Message-ID: <59b80d78.-1@webcrossing.la2eafNXanI>
Date: Wed, 25 Feb 2009 16:22:12 -0800
Lines: 48
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit