Article View: adobe.scripting.indesign
Article #16434Re: Margin notes/hanging side heads
From: Kari Puikkonen
Date: Mon, 15 Sep 2003 10:51
Date: Mon, 15 Sep 2003 10:51
139 lines
6817 bytes
6817 bytes
Stubborn is my middle name!
Here is the script that do the trick: margin notes/hanging side heads on the left side pages at left margin and on the right side pages at right margin.
Part ONE of the script:
-- Change margin notes paragraph style on right side pages
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
set thePage to (name of parent of parent text frame of paragraph x of theStory) as integer
if thePage mod 2 = 0 then
applyParagraph(x, theStory) of me
end if
end if
end repeat
end try
end repeat
end tell
on applyParagraph(paraNum, storyRef)
tell application "InDesign 2.0.2"
set newStyle to "MarginNotesRight" -- name of paragraph style you want to apply
repeat
set applied paragraph style of paragraph paraNum of storyRef to newStyle
exit repeat
end repeat
end tell
end applyParagraph
--Make inline frame son left side pages
tell application "InDesign 2.0.2"
set myDocument to active document
if horizontal measurement units of view preferences of myDocument is not points or �
vertical measurement units of view preferences of myDocument is not points then
set myOldViewPreferences to properties of view preferences of myDocument
set horizontal measurement units of view preferences of myDocument to points
set vertical measurement units of view preferences of myDocument to points
set myResetUnits to true
else
set myResetUnits to false
end if
set myStory to parent story of selection
set paraStyles to name of applied paragraph style of every paragraph of myStory
repeat with n from 1 to count of paraStyles
if item n of paraStyles = "MarginNotes" then -- name of paragraph style you want to affect
set theText to text contents of paragraph n of myStory
set theFrame to parent text frame of character 1 of paragraph n of myStory
set theBounds to visible bounds of theFrame
set theNewBounds to {0, 0, 58, ((item 4 of theBounds) - (item 2 of theBounds) + 90)}
tell active spread of active window
set myNewFrame to make text frame
end tell
set visible bounds of myNewFrame to theNewBounds
set contents of insertion point 1 of myNewFrame to theText
set applied paragraph style of paragraph 1 of myNewFrame to paragraph style "MarginNotes" of document 1
delete characters 1 through -2 of paragraph n of myStory
set applied paragraph style of paragraph n of myStory to paragraph style "Inline" of document 1 -- name of inline paragraph style you want to affect
activate
select myNewFrame
cut
select insertion point 1 of paragraph n of myStory
paste
end if
end repeat
end tell
--Make inline frame son right side pages
tell application "InDesign 2.0.2"
set myDocument to active document
if horizontal measurement units of view preferences of myDocument is not points or �
vertical measurement units of view preferences of myDocument is not points then
set myOldViewPreferences to properties of view preferences of myDocument
set horizontal measurement units of view preferences of myDocument to points
set vertical measurement units of view preferences of myDocument to points
set myResetUnits to true
else
set myResetUnits to false
end if
set myStory to parent story of selection
set paraStyles to name of applied paragraph style of every paragraph of myStory
repeat with n from 1 to count of paraStyles
if item n of paraStyles = "MarginNotesRight" then -- name of paragraph style you want to affect
set theText to text contents of paragraph n of myStory
set theFrame to parent text frame of character 1 of paragraph n of myStory
set theBounds to visible bounds of theFrame
set theNewBounds to {0, 0, 58, ((item 4 of theBounds) - (item 2 of theBounds) + 90)}
tell active spread of active window
set myNewFrame to make text frame
end tell
set visible bounds of myNewFrame to theNewBounds
set contents of insertion point 1 of myNewFrame to theText
set applied paragraph style of paragraph 1 of myNewFrame to paragraph style "MarginNotesRight" of document 1
delete characters 1 through -2 of paragraph n of myStory
set applied paragraph style of paragraph n of myStory to paragraph style "InlineRight" of document 1 -- name of inline paragraph style you want to affect
activate
select myNewFrame
cut
select insertion point 1 of paragraph n of myStory
paste
end if
end repeat
end tell
--Change inline frames paragraph style on right side pages
tell application "InDesign 2.0.2"
set paraStyle to "Inline" -- name of paragraph style you want to affect
set myStory to object reference of parent story of selection
try
set theParaStyles to name of applied paragraph style of object reference of paragraphs of myStory
repeat with x from 1 to count of theParaStyles
if paraStyle = contents of item x of theParaStyles then
set thePage to (name of parent of parent text frame of paragraph x of myStory) as integer
if thePage mod 2 = 0 then
applyInlineParaStyle(x, myStory) of me
end if
end if
end repeat
end try
end tell
on applyInlineParaStyle(paraNum, storyRef)
tell application "InDesign 2.0.2"
repeat
set changeStyle to "InlineRight" -- name of paragraph style you want to apply
set applied paragraph style of paragraph paraNum of storyRef to changeStyle
exit repeat
end repeat
end tell
end applyInlineParaStyle
Technical Details
Message-ID:
<2ccd5677.1@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!priapus.visi.com!news-out.visi.com!petbe.visi.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.arcor-online.net!newsfeed01.sul.t-online.de!t-online.de!webxReferences:
<2ccd5677.-1@webx.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: f939a,e514e8aa8c4da606 X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2003-09-15 04:07:42 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!priapus.visi.com!news-out.visi.com!petbe.visi.com!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.1@webx.la2eafNXanI> Date: Mon, 15 Sep 2003 03:51:33 -0700 References: <2ccd5677.-1@webx.la2eafNXanI> Lines: 174 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit