Article View: adobe.scripting.indesign
Article #20479Re: Merging merged cells
From: Olav Kvern
Date: Mon, 15 Jul 2002 18:02
Date: Mon, 15 Jul 2002 18:02
41 lines
2981 bytes
2981 bytes
Tobias--
Actually, Cell.Merge can merge multiple cells. Note that the cellToMergeWith parameter is optional, and that the ItemByRange reference method returns a Cell object. Here's an example of a few ways to use the Merge method:
Dim myInDesign As InDesign.Application
Dim myTable As InDesign.Table
Set myInDesign = CreateObject("InDesign.Application.2.0")
Set myDocument = myInDesign.Documents.Add
Set myPage = myDocument.Pages.Item(1)
Set myTextFrame = myPage.TextFrames.Add
myX1 = myPage.MarginPreferences.MarginLeft
myY1 = myPage.MarginPreferences.MarginTop
myX2 = myDocument.DocumentPreferences.PageWidth - myPage.MarginPreferences.MarginRight
myY2 = myDocument.DocumentPreferences.PageHeight - myPage.MarginPreferences.MarginBottom
myTextFrame.GeometricBounds = Array(myY1, myX1, myY2, myX2)
Set myTable = myTextFrame.ParentStory.Tables.Add
myTable.RowCount = 6
myTable.ColumnCount = 6
myTable.Width = myDocument.DocumentPreferences.PageWidth - (myPage.MarginPreferences.MarginRight + myPage.MarginPreferences.MarginLeft)
Rem Use the ItemByRange reference method to refer to cells 2-5 in row 1
Set myCell = myTable.Rows.Item(1).Cells.ItemByRange(myTable.Rows.Item(1).Cells.Item(2), myTable.Rows.Item(1).Cells.Item(5)).Item(1)
Rem Merge cells 2-5 in row 1
myCell.Merge
Rem Use the ItemByRange reference method to refer to cells 1-6 in column 1
Set myCell = myTable.Columns.Item(1).Cells.ItemByRange(myTable.Columns.Item(1).Cells.Item(1), myTable.Columns.Item(1).Cells.Item(6)).Item(1)
Rem Merge cells 1-6 in row 1
myCell.Merge
Rem use the optional cellToMergeWith parameter to merge two adjacent cells in the last row
myTable.Rows.Item(myTable.RowCount).Cells.Item(3).Merge myTable.Rows.Item(myTable.RowCount).Cells.Item(4)
Rem Next, let's say you've merged a series of cells using the ItemByRange reference method...
Set myCell = myTable.Rows.Item(3).Cells.ItemByRange(myTable.Rows.Item(3).Cells.Item(2), myTable.Rows.Item(3).Cells.Item(4)).Item(1)
myCell.Merge
Rem ...and then want to add another cell to the merged range of cells (what was cell 6 has become cell 3 of this row).
myCell.Merge myTable.Rows.Item(3).Cells.Item(3)
Hope this helps!
Thanks,
Ole
Technical Details
Message-ID:
<ef9a72e.0@WebX.aaQKaf7vad4>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!sn-xit-08!supernews.com!newsswitch.lcs.mit.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<ef9a72e.-1@WebX.aaQKaf7vad4>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,712fa7414377d02b X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2002-07-15 11:10:51 PST From: "Olav Kvern" <okvern@adobe.com> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!sn-xit-08!supernews.com!newsswitch.lcs.mit.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: Re: Merging merged cells Message-ID: <ef9a72e.0@WebX.aaQKaf7vad4> Date: Mon, 15 Jul 2002 11:02:47 -0700 References: <ef9a72e.-1@WebX.aaQKaf7vad4> Lines: 55 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit