🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #20371

Re: Dave Saunders' Running Heads Script

#20371
From: Jay Fraser
Date: Fri, 26 Jul 2002 16:37
81 lines
4400 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 
Technical Details
Message-ID: <ef9de98.2@WebX.aaQKaf7vad4>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-04!supernews.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX
References: <ef9de98.-1@WebX.aaQKaf7vad4>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f939a,37e35bfe49790ac7
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2002-07-26 10:13:27 PST
From: "Jay Fraser" <jayfraser@yahoo.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-04!supernews.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX
Newsgroups: adobe.scripting.indesign
Subject: Re: Dave Saunders' Running Heads Script
Message-ID: <ef9de98.2@WebX.aaQKaf7vad4>
Date: Fri, 26 Jul 2002 09:37:50 -0700
References: <ef9de98.-1@WebX.aaQKaf7vad4>
Lines: 91
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit