Article View: adobe.scripting.indesign
Article #19546Re: Repeating table header rows
From: Shane Stanley
Date: Thu, 05 Dec 2002 10:39
Date: Thu, 05 Dec 2002 10:39
69 lines
3261 bytes
3261 bytes
in article 1de6adf5.6@WebX.la2eafNXanI, Kari Puikkonen wrote:
> Does anybody know how to do this with AppleScript?
I don't believe there's an easy solution to the problem (in VB either, I
suspect).
There are two problems:
(a) There's no way that I can see that will tell you what text frame a row
belongs to; and
(b) Even if you do know, adding a new header row of a different (smaller)
size might cause the table to reflow, so the header could end up in the
previous frame.
I suspect the nearest we can do is ignore (b), and test for (a) by getting
the baseline of the first insertion point of a row, and assume that if the
value is less than the previous row's value, it's in a new column. This will
miss odd layouts and cases where tables jump images, but it should still be
useful in a lot of cases.
(I guess you could use the same test after you add a row to test for (b),
but then you'd have to decide how to force the turn, and that could get
complicated; you would essentially be looking at a routine to vertically
justify the table, or else reduce the height of the parent frame.)
With those caveats, you could use something like this:
tell application "InDesign 2.0.1"
set topRow to 2
tell document 1
tell table 1 of selection
-- get properties of header row
set theProps to properties of every cell of row 1
set colCount to count of items of theProps
-- get baseline of second row
set theBaseline1 to baseline of insertion point 1 of parent story of cell
topRow of column 1
repeat
try -- in case of overset
-- get baseline of next row
set theBaseline2 to baseline of insertion point 1 of parent story of
cell (topRow + 1) of column 1
on error -- in overset
exit repeat
end try
if theBaseline2 � theBaseline1 then -- row is higher than previous row
make new row at end of row topRow with properties {column
count:colCount}
repeat with j from 1 to colCount
set properties of cell j of row (topRow + 1) to item j of theProps
end repeat
end if
-- move to next row
set topRow to topRow + 1
set theBaseline1 to theBaseline2
end repeat
end tell
end tell
end tell
Oh, and this assumes that the contents of each header cell is in a uniform
style.
Still, better than nothing, I guess...
--
Shane Stanley, sstanley@myriad-com.com.au
Technical Details
Message-ID:
<BA1577CE.46607%sstanley@myriad-com.com.au>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-04!supernews.com!iad-peer.news.verio.net!news.verio.net!news.maxwell.syr.edu!nntp.infostrada.it!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<1de6adf5.-1@WebX.la2eafNXanI> <1de6adf5.6@WebX.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: f939a,19663770ef9645f5 X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2002-12-05 03:08:04 PST From: Shane Stanley <sstanley@myriad-com.com.au> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-04!supernews.com!iad-peer.news.verio.net!news.verio.net!news.maxwell.syr.edu!nntp.infostrada.it!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: Re: Repeating table header rows Message-ID: <BA1577CE.46607%sstanley@myriad-com.com.au> Date: Thu, 5 Dec 2002 02:39:08 -0800 References: <1de6adf5.-1@WebX.la2eafNXanI> <1de6adf5.6@WebX.la2eafNXanI> Lines: 84 User-Agent: Microsoft-Outlook-Express-Macintosh-Edition/5.0.6 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit