🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #16435

Re: Margin notes/hanging side heads

#16435
From: Kari Puikkonen
Date: Mon, 15 Sep 2003 10:56
116 lines
4999 bytes
Part TWO of the script:



-- Insert table 
tell application "InDesign 2.0.2" 
	set paraStyle to "MarginNotes" -- name of paragraph style you want to affect 
	set theStories to object reference of stories of document 1 
	repeat with theStory in theStories 
		try 
			set theParaStyles to name of applied paragraph style of object reference of paragraphs of theStory 
			repeat with x from 1 to count of theParaStyles 
				if paraStyle = contents of item x of theParaStyles then 
					insertTable(x, theStory) of me 
				end if 
			end repeat 
		end try 
	end repeat 
end tell

tell application "InDesign 2.0.2" 
	set paraStyle to "MarginNotesRight" -- name of paragraph style you want to affect 
	set theStories to object reference of stories of document 1 
	repeat with theStory in theStories 
		try 
			set theParaStyles to name of applied paragraph style of object reference of paragraphs of theStory 
			repeat with x from 1 to count of theParaStyles 
				if paraStyle = contents of item x of theParaStyles then 
					insertTable(x, theStory) of me 
				end if 
			end repeat 
		end try 
	end repeat 
end tell

on insertTable(paraNum, storyRef) 
	tell application "InDesign 2.0.2"

		-- Get bounds 
		set myDocument to active document 
		set myPage to page 1 of myDocument 
		set myBounds to myGetBounds(page 1 of myDocument, myDocument) of me 
		set myWidth to item 4 of myBounds

		--Deletes extra last chracter at the end of the chosen paragraph. 
		repeat 
			set theDeleteCharacter to character -1 of paragraph paraNum of storyRef 
			delete character -1 of paragraph paraNum of storyRef 
			exit repeat 
		end repeat

		--Makes table of the chosen paragraph. 
		repeat 
			tell characters 1 through -1 of paragraph paraNum of storyRef 
				set myTable to make table with properties {width:myWidth + 90, row count:1, column count:2, space before:0, space after:0, top border stroke weight:0, bottom border stroke weight:0, left border stroke weight:0, right border stroke weight:0} 
				tell myTable 
					set properties of row 1 to {minimum height:"14.5", inner column stroke weight:"0", right inset:"0", left inset:"0", top inset:"0", bottom inset:"0"} 
					set properties of column 1 to {width:90} 
					set properties of column 2 to {width:myWidth} 
				end tell 
			end tell 
			exit repeat 
		end repeat 
	end tell 
end insertTable

on myGetBounds(myPage, myDocument) 
	tell application "InDesign 2.0.2" 
		set myPageWidth to page width of document preferences of myDocument 
		set myPageHeight to page height of document preferences of myDocument 
		set myX1 to margin left of margin preferences of myPage 
		set myY1 to margin top of margin preferences of myPage 
		set myX2 to myPageWidth - (margin right of margin preferences of myPage) 
		set myY2 to myPageHeight - (margin bottom of margin preferences of myPage) 
		return {myY1, myX1, myY2, myX2} 
	end tell 
end myGetBounds

--Move text from cell 1 to cell 2 on right side pages 
tell application "InDesign 2.0.2" 
	set paraStyle to "MarginNotesRight" -- name of paragraph style you want to affect 
	set theStories to object reference of stories of document 1 
	repeat with theStory in theStories 
		try 
			set theParaStyles to name of applied paragraph style of object reference of paragraphs of theStory 
			repeat with x from 1 to count of theParaStyles 
				if paraStyle = contents of item x of theParaStyles then 
					moveCellText(x, theStory) of me 
				end if 
			end repeat 
		end try 
	end repeat 
end tell

on moveCellText(paraNum, storyRef) 
	tell application "InDesign 2.0.2" 
		repeat 
			set myTable to table 1 of parent text frame of paragraph paraNum of storyRef 
			select text of cell 1 of myTable 
			set theCell to parent of item 1 of selection 
			set theTable to parent of theCell 
			move text of cell 1 of row 1 of theTable to after insertion point -1 of cell 2 of row 1 of theTable 
			exit repeat 
		end repeat 
	end tell 
end moveCellText



Huh!

What a job!

I certainly and humbly hope that these kind of things would be easier to do in InDesign 3!

Kari the Exhausted Man
Technical Details
Message-ID: <2ccd5677.2@webx.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!newsfeeds.sol.net!news.maxwell.syr.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.arcor-online.net!newsfeed01.sul.t-online.de!t-online.de!webx
References: <2ccd5677.-1@webx.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,e514e8aa8c4da606
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-09-15 04:07:43 PST
From: "Kari Puikkonen" <kari.puikkonen@welho.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!newsfeeds.sol.net!news.maxwell.syr.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.arcor-online.net!newsfeed01.sul.t-online.de!t-online.de!webx
Newsgroups: adobe.scripting.indesign
Subject: Re: Margin notes/hanging side heads
Message-ID: <2ccd5677.2@webx.la2eafNXanI>
Date: Mon, 15 Sep 2003 03:56:15 -0700
References: <2ccd5677.-1@webx.la2eafNXanI>
Lines: 129
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit