2 Replies Latest reply on Feb 21, 2011 2:04 AM by Mohan06

    How to resolve merge empty cells JS error

    Mohan06

      Hi Scripters

       

      I am new to scripting and now looking into it.

       

      I am trying to write a table script for that, I found one merge empty cells JS from Jongware GfBROo

      table = app.selection[0];
      if (!(table instanceof Table)) table = table.parent;
      if (table instanceof Cell) table = table.parent;
      if (table instanceof Table)
      {
           for (r=0; r<table.rows.length; r++)
           {
                c = 0;
                while (c < table.rows[r].cells.length)
                {
                     while (c < table.rows[r].cells.length &&
                          table.rows[r].cells[c].contents.length > 0)
                          c++;
                     while (c < table.rows[r].cells.length &&
                          table.rows[r].cells[c].contents.length == 0)
                          table.rows[r].cells[c].merge (table.rows[r].cells[c-1]);
                }
           }
      }

       

      Even though for almost tables it's working like charm but in some of the cases it's falling me in trouble by showing this error "Object is Invalid" at bold face line.

       

      Though I can guess some problem wolud be with those tables but I am not able to catch it.

       

      Could any one any way suggest me to resolve this error.