Article View: adobe.scripting.indesign
Article #16261Re: [VB] Center a right aligned paragraphs in a table
From: Guy Verville
Date: Sat, 27 Sep 2003 13:06
Date: Sat, 27 Sep 2003 13:06
66 lines
2647 bytes
2647 bytes
Thank you for all. I have succeeded creating this script that align a simple selection (one column) in a table.
Dim k, SelectName, NumCells
Set myindesign = CreateObject("InDesign.Application.2.0")
Set MySelection = MyIndesign.Selection.Item(1)
SelectName= TypeName(MySelection)
Select Case SelectName
Case "Cell", "Column"
Set myCells = MySelection.Cells
NumCells= MyCells.count
ColWidth = MyCells.Item(1).Width
'Resets Cell Insets and Paragraphs Indents
For i =1 to NumCells
Set OneCell =MyCells.Item(i)
With OneCell
.leftinset=0
.rightinset=0
NbrPara=.Paragraphs.Count
End With
For k=1 to NbrPara
Set MyPara= OneCell.Paragraphs.Item(k)
With MyPara
.Justification=idRight
.LeftIndent=0
.RightIndent=0
End With
Next
Next
'Gets the biggest Line in the selected cells
Biggest=0
For k=1 to NumCells
Set OneCell =MyCells.Item(k)
NbrLignes= OneCell.Textlines.Count
For i=1 to NbrLignes
Set OneLine=OneCell.Textlines.Item(i)
Set IP = Oneline.InsertionPoints
NbrIP=IP.Count
StartIP = OneLine.HorizontalOffset
EndIP= IP.Item(NbrIP).HorizontalOffset
LenghtIP=EndIP-StartIP
If LenghtIP > Biggest Then Biggest=LenghtIP
Next
Next
'This is the Right Indent to apply
RI=(ColWidth-Biggest)/2
'Applies the RightIndent to all the paragraphs
For i =1 to NumCells
Set OneCell =MyCells.Item(i)
NbrPara=OneCell.Paragraphs.Count
For k=1 to NbrPara
Set MyPara= OneCell.Paragraphs.Item(k)
With MyPara
.Justification=idRight
.RightIndent=RI
End With
Next
Next
Case Else
MsgBox "You've selected " & SelectName &
". Please select at least two cells."
End Select
Technical Details
Message-ID:
<2ccd7909.10@webx.la2eafNXanI>Path:
arc1-ca.pugleaf.net!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-01!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.arcor-online.net!newsfeed01.sul.t-online.de!t-online.de!webxReferences:
<2ccd7909.-1@webx.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,87869e3f37548296 X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2003-09-27 06:08:36 PST From: "Guy Verville" <taddeus@spamcop.net> Path: arc1-ca.pugleaf.net!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-01!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.arcor-online.net!newsfeed01.sul.t-online.de!t-online.de!webx Newsgroups: adobe.scripting.indesign Subject: Re: [VB] Center a right aligned paragraphs in a table Message-ID: <2ccd7909.10@webx.la2eafNXanI> Date: Sat, 27 Sep 2003 06:06:52 -0700 References: <2ccd7909.-1@webx.la2eafNXanI> Lines: 71 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit