Article View: adobe.scripting.indesign
Article #19570Re: Auto Numbering
From: amjb
Date: Fri, 06 Dec 2002 13:21
Date: Fri, 06 Dec 2002 13:21
46 lines
2389 bytes
2389 bytes
I am not to good at apple script, so am finding this a little hard, but here is my script, thanks
I have named my headers H1, H2, H3,
property topheads : {"H1", "p1"}
property secondheads : {"H2", "p1"}
property thirdheads : {"H3", "p1"}
-- this script auto-numbers headings to a depth of three
-- first, concatenate all head styles so other paras are
-- easily ignored
copy topheads to allheads
repeat with n from 1 to count of secondheads
copy item n of secondheads to end of allheads
end repeat
repeat with n from 1 to count of thirdheads
copy item n of thirdheads to end of allheads
end repeat
tell application "InDesign 2.0.1"
set myStory to parent story of selection
set theLim to count of paragraphs of myStory
set topCount to 1
set secondCount to 1
set thirdCount to 1
repeat with n from 1 to theLim
set myStyle to name of applied paragraph style of paragraph n of myStory
if myStyle is in topheads then
set word 1 of paragraph n of myStory to topCount as string
set topCount to topCount + 0.1
set secondCount to 1
set thirdCount to 1
else if myStyle is in secondheads then
set word 1 of paragraph n of myStory to (topCount + 1) as string
set word 2 of paragraph n of myStory to secondCount as string
set secondCount to secondCount + 0.1
set thirdCount to 1
else if myStyle is in thirdheads then
set word 1 of paragraph n of myStory to (topCount - 1) as string
set word 2 of paragraph n of myStory to (secondCount - 1) as string
set word 3 of paragraph n of myStory to thirdCount as string
set thirdCount to thirdCount + 0.1
end if
end repeat
end tell
Technical Details
Message-ID:
<1de6d01c.8@WebX.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!easynet-quince!easynet.net!feed1.news.be.easynet.net!newsfeed.online.be!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<1de6d01c.-1@WebX.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,e7d83a70f4be8fa9 X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2002-12-06 05:37:38 PST From: amjb <adam44@btopenworld.com> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!easynet-quince!easynet.net!feed1.news.be.easynet.net!newsfeed.online.be!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: Re: Auto Numbering Message-ID: <1de6d01c.8@WebX.la2eafNXanI> Date: Fri, 6 Dec 2002 05:21:08 -0800 References: <1de6d01c.-1@WebX.la2eafNXanI> Lines: 48 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit