🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #15909

AS - IND 2 - image placing

#15909
From: Fernando G. Jensen
Date: Mon, 03 Nov 2003 10:09
66 lines
3357 bytes
This script replaces different text with different inline files... almost.

After choosing a folder of graphic files (no error handling made for non-graphic files), InDesign creates paragraph styles with the names found in the folder. It then searches for the created names, and adds the style to the found text in every frame in InDesign. In the last part of this script, the chosen files should be placed instead of the found text... but than doesn't happen. According to the "Event Log" there is nothing wrong, and the script has successfully accomplished its goal.

Everything works according to plan until the paragraph (at the end of the script):
place myPicture on....

If I change the word "searchWord" for "myParagraphStyle", in the previously mentioned paragraph, 1 graphic file is placed before and error occurs.

Can anyone tell what I'm dong wrong?

Thanks
Fernando

-- choose folder
tell application "Finder"
	set myFolder to (choose folder with prompt "Choose a folder:")
	set myCount to count files in folder myFolder
	if myCount = 0 then
		display dialog "The folder is empty. Try another folder" buttons {"Cancel"} default button 1
	end if
	set searchWord to the name of every file of myFolder
	set folderPath to myFolder as string
end tell

-- make paragraph styles
tell application "InDesign 2.0.2"
	activate
	repeat with i from 1 to count of searchWord
		set mySearch to item i of searchWord
		set myParagraph to item i of searchWord
		tell document 1
			set myParagraphStyle to make paragraph style
			tell myParagraphStyle
				set myParagraphStyle to item i of searchWord
				set name to item i of searchWord
				set applied font to "Helvetica Neue"
				set font style to "55 Roman"
				set point size to 10
				set leading to 10
				set fill color to active document's color "Black"
				set justification to left
			end tell
		end tell
	end repeat
end tell

-- search text and replace with inline graphic
tell application "InDesign 2.0.2"
	activate
	set find preferences to nothing
	set change preferences to nothing
	tell document 1
		-- with timeout of 1000 seconds (use if doc is long)
		repeat with i from 1 to count of searchWord
			set mySearch to item i of searchWord
			set myParagraphStyle to paragraph style (item i of searchWord)
			search with find attributes {find text:mySearch} with change attributes {change text:mySearch, applied paragraph style:myParagraphStyle}
		end repeat
		repeat with i from 1 to count of searchWord
			set myPicture to folderPath & item i of searchWord
			place myPicture on (every text style range of every story where applied paragraph style is item i of searchWord)
		end repeat
		-- end timeout (use if doc is long)
	end tell
end tell
Technical Details
Message-ID: <2cce25ce.-1@webx.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!webx

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,d4e0fdd946983710,start
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-11-03 02:37:39 PST
From: "Fernando G. Jensen" <fgj@eniro.dk>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!webx
Newsgroups: adobe.scripting.indesign
Subject: AS - IND 2 - image placing
Message-ID: <2cce25ce.-1@webx.la2eafNXanI>
Date: Mon, 3 Nov 2003 02:09:28 -0800
Lines: 79
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit