2 Replies Latest reply on Aug 2, 2010 1:46 PM by wjnp2000

    [CS4][JS] Merge cells in a table??

    wjnp2000 Level 2

      Hi everybody!

       

      I make little script to apply a group of comands in the text. I select some text, apply Paragraph style, transform to Table apply styles (table and cell styles) and unfortunatelly each line stay in a different cell. I need to make all in one cell only.

      How do I do this? Please, help.

       

      This is the script:

       

      myText=app.selection[0].appliedParagraphStyle = "Norma DO";
      myText=app.selection[0];
      myTable = myText.convertToTable("\t", "\r",);
      myTable.appliedTableStyle = "DOU";
      myTable.cells.itemByRange(0,-1).appliedCellStyle = "Célula DOU";
      myTable.cells.itemByRange(0,-1).clearCellStyleOverrides;
      myTable.cells.Merge;

       

      This last line doesn't work, gives error.

       

      Thanks.

       

      Wagner

        • 1. Re: [CS4][JS] Merge cells in a table??
          [Jongware] Most Valuable Participant

          myTable.cells.Merge is not a valid Javascript command -- for various reasons.

           

          First, the Merge command is not a valid function on cells. You probably meant 'merge'.

          Then, merge does not work on 'cells' -- an array of cells. Rather, it works on either one single cell (and you'd have to tell it with what other cell to merge), or on an entire collection of cells.

          Finally, since this is a function, it needs a pair of parentheses.

           

          So this does work:

           

          myTable.cells.itemByRange(0,-1).merge();

           

          specifying a collection to merge, or, alternatively,

           

          myTable.cells.firstItem().merge(myTable.cells.lastItem());

           

          telling to merge everything from the first cell to the last cell.

          • 2. Re: [CS4][JS] Merge cells in a table??
            wjnp2000 Level 2

            That's it!

             

            Thanks a lot Jongware.

             

            It works fine.