2 Replies Latest reply on Sep 5, 2008 3:46 AM by (frekfeng)

    Merge table cells

      Hi all:
      In Indesign server cs3, I want to do some merges on the cells
      var myDocument = app.open("c:/test.indd")
      var page1 = myDocument.pages.item(0)
      var textFrame1 = page1.textFrames.item(0)
      var oTableAvail = textFrame1.insertionPoints.item(-1).tables.add();
      oTableAvail.bodyRowCount = 7;
      oTableAvail.columnCount = 3;
      oTableAvail.width = 50;
      oTableAvail.rows[1].cells[2].contents = "test"
      oTableAvail.rows[1].cells[2].merge(oTableAvail.rows[5].cells[2]); -- Exception here, it said Invalid value for parameter 'width' of event 'merge'. Expected Cell, Row or Column, but received nothing.

      but this is right:
      any help? Thanks
        • 1. Re: Merge table cells
          Level 1
          Your problem is that the first merge is reducing the number of cells in row 5 from 3 to 2, so there isn't a rows[5].cells[2] when you try to address it.

          You should use cell addresses rather than row/column offsets when merging. Like this:

          oTableAvail.cells.item("2:1").contents = "test"

          The name of the cell doesn't change because of merging even though the relative address of the cell does.

          By the way, oTableAvail.cells.item("2:1") executes much faster (as well as more accurate) than either oTableAvail.rows[1].cells[2] or oTableAvail.columns[2].cells[1].


          • 2. Re: Merge table cells
            Level 1
            Thanks a lot.