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

    Merge table cells

    Level 1
      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[4].cells[0].merge(oTableAvail.rows[5].cells[0]);
      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.
      myDocument.save();
      app.documents.item(0).close();
      app.quit()

      but this is right:
      oTableAvail.rows[1].cells[2].merge(oTableAvail.rows[6].cells[2]);
      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"
          oTableAvail.cells.item("0:4").merge(oTableAvail.cells.item("0:5"));
          oTableAvail.cells.item("2:1").merge(oTableAvail.cells.item("2:5"));

          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].

          Dave

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