🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #21031

Re: Running Head Script

#21031
From: Dave Saunders
Date: Sat, 18 May 2002 22:06
41 lines
4092 bytes
Here's the script: 

property StoryLabel : "Directory" property HeadLabel : "Running Head" property HeadStyle : "Headdir" 

-- This script creates running heads or updates existing -- ones based on the content of the -- pages. It assumes that there's one main story to which -- the running heads relate; all other stories are ignored. 

tell application "InDesign 2.0.1"  -- go to the first page and find the story  set active spread of active window to parent of page 1 of document 1  tell active spread of active window   try    set theFirstFrame to text frame 1 whose label is StoryLabel   on error    activate    display dialog "Can't find main story on first page."   end try  end tell 

 -- now we know the story exists, we can do the rest  -- in a loop 

 set theStory to object reference of parent story of theFirstFrame 

 set Head1 to "This should not appear"  set Head2 to "This should not appear" 





 repeat with x from 1 to count of text frames of theStory   if x mod 2 != 0 then    -- Every page has two frames on it, so ignore even numbered ones 

   -- First we need to check to see if this page starts with a Headdir 

   if name of applied paragraph style of paragraph 1 of text frame x of theStory = "Headdir" then     set Head1 to characters 1 through -2 of paragraph 1 of text frame x of theStory     copy Head1 to Head2    else     copy Head2 to Head1    end if 

   set theTextRef to object reference of text from character 1 of paragraph 1 of text frame x of theStory to character -1 of paragraph -1 of text frame (x + 1) of theStory 

   set find preferences to nothing    set theStyle to paragraph style "Headdir" of document 1    set theFoundItems to search theTextRef with find attributes {applied paragraph style:theStyle}    try     if theFoundItems != {} then      set Head2 to characters 1 through -2 of item -1 of theFoundItems     end if    end try    if Head1 = Head2 then     set theHead to Head1    else     set theHead to Head1 & " � " & Head2    end if 

   -- Now we have constructed the head info, it's time to set it 

   set thePage to parent of text frame x of theStory    tell thePage     try      set theHeadFrame to (text frame 1 whose label is "Running Head")     on error      try       -- doesn't yet exist, so we need to release it from the master page       set theHeadFrame to (master page item 1 whose label is "Running Head")      on error       -- master page doesn't have a running head       tell application "InDesign 2.0.1"        activate        display dialog "Master Pages doesn't have a running head."        return       end tell      end try     end try    end tell    set theTextRuns to object reference of text style ranges of paragraph 1 of theHeadFrame    repeat with y from 1 to count of theTextRuns     try      if name of applied character style of item y of theTextRuns is HeadStyle then       set contents of item y of theTextRuns to theHead       exit repeat      end if     end try    end repeat 

  end if  end repeat 

 return 

end tell 

The script also assumes that the main story starts on the first page of the document. I'll probably change that in a later version. 

Dave
Technical Details
Message-ID: <ef89cf8.0@WebX.aaQKaf7vad4>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!supernews.com!telocity-west!TELOCITY!hub1.nntpserver.com!newsfeed.newzpig.com!priapus.visi.com!news-out.visi.com!hermes.visi.com!news.tele.dk!small.news.tele.dk!194.213.69.151!news.algonet.se!algonet!news000.worldonline.se!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!WebX
References: <ef89cf8.-1@WebX.aaQKaf7vad4>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f939a,1646cc11453fc57,start
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2002-05-18 15:37:26 PST
From: "Dave Saunders" <daves@pdsassoc.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!supernews.com!telocity-west!TELOCITY!hub1.nntpserver.com!newsfeed.newzpig.com!priapus.visi.com!news-out.visi.com!hermes.visi.com!news.tele.dk!small.news.tele.dk!194.213.69.151!news.algonet.se!algonet!news000.worldonline.se!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!WebX
Newsgroups: adobe.scripting.indesign
Subject: Re: Running Head Script
Message-ID: <ef89cf8.0@WebX.aaQKaf7vad4>
Date: Sat, 18 May 2002 15:06:49 -0700
References: <ef89cf8.-1@WebX.aaQKaf7vad4>
Lines: 112
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit