How to resolve merge empty cells JS error
Copy link to clipboard
Copied
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.cells.length)
{
while (c < table.rows.cells.length &&
table.rows.cells.contents.length > 0)
c++;
while (c < table.rows.cells.length &&
table.rows.cells.contents.length == 0)
table.rows.cells.merge (table.rows.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.
Copy link to clipboard
Copied
As Marc Autret explained in this post, couldn't it be related to some overflowing text which has a consequence is not available to contents.length ?
http://forums.adobe.com/message/3454859#3454859
Loic
http://www.loicaigon.com
Copy link to clipboard
Copied
Thanks for reply Loic_aigon
As Marc suggested in discussion, I used
myTable.rows
But above syntex falls script to infinite loop.
any other help will be appreciated.

