Article View: adobe.scripting.indesign
Article #19635Re: Repeating table header rows
From: roberto soto
Date: Wed, 04 Dec 2002 18:56
Date: Wed, 04 Dec 2002 18:56
83 lines
3289 bytes
3289 bytes
Hi,
READ THIS!
Here is the first "spaguetti" code to solve this problem. Many details are missing.
1. Only work with simple Row Headers, NO MERGED CELL (for now I working on it)
2. You need to define how many row you want in each text frame
TOTAL_ROWS = ? (can be at run time)
3. In the last text frame of flow table, put extra space, script don't check that
Now try it and give me some comment (I don't have Mac)
Dim myInDesign As Indesign.Application
Dim myHeader As Indesign.Row
Dim myRow As Indesign.Row
Private Sub Command2_Click()
Set myInDesign = CreateObject("InDesign.Application.2.0")
TOTAL_ROWS = 15
Set mySelection = myInDesign.Selection
If mySelection.Count > 0 Then
Select Case TypeName(mySelection.Item(1))
Case "TextFrame"
Set myTextFrame = mySelection.Item(1)
If TypeName(myTextFrame.PreviousTextFrame) <> "TextFrame" Then
Set myTable = myTextFrame.Tables.Item(1)
Set myHeader = myTable.Rows.Item(1)
Ancho = myHeader.Height + myTable.Rows.Item(2).Height * (TOTAL_ROWS + 1)
Cont = 0
While (TypeName(myTextFrame) = "TextFrame")
myBounds = myTextFrame.GeometricBounds
myB1 = myBounds(0)
myB2 = myBounds(1)
myB3 = myBounds(2)
myB4 = myBounds(3)
myB3 = Ancho + myB1
myTextFrame.GeometricBounds = Array(myB1, myB2, myB3, myB4)
If Cont > 0 Then
Set myRow = myTable.Rows.Add(idAfter, myTable.Rows.Item(TOTAL_ROWS + (Cont - 1) * TOTAL_ROWS + Cont))
Ok = ChangeRow(myRow, myHeader)
End If
Set myTextFrame = myTextFrame.NextTextFrame
Cont = Cont + 1
Wend
Else
MsgBox "Select The Text Frame at the begining of the table"
End If
End Select
End If
End Sub
Function ChangeRow(myRow, myHeader)
myRow.Height = myHeader.Height
For myCellCounter = 1 To myHeader.Cells.Count
myRow.Cells.Item(myCellCounter).TextContents = myHeader.Cells.Item(myCellCounter).TextContents
'Assuming that in each Header Cell are only one Paragraph
myRow.Cells.Item(myCellCounter).Paragraphs.Item(1).ParagraphStyle = _
myHeader.Cells.Item(myCellCounter).Paragraphs.Item(1).ParagraphStyle
myRow.Cells.Item(myCellCounter).Paragraphs.Item(1).CharacterStyle = _
myHeader.Cells.Item(myCellCounter).Paragraphs.Item(1).CharacterStyle
Next
End Function
Roberto
Technical Details
Message-ID:
<1de6adf5.5@WebX.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-04!supernews.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<1de6adf5.-1@WebX.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,19663770ef9645f5 X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2002-12-04 11:08:06 PST From: "roberto soto" <roberto1soto@hotmail.com> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!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: Repeating table header rows Message-ID: <1de6adf5.5@WebX.la2eafNXanI> Date: Wed, 4 Dec 2002 10:56:36 -0800 References: <1de6adf5.-1@WebX.la2eafNXanI> Lines: 92 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit