Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to resolve merge empty cells JS error

New Here ,
Feb 20, 2011 Feb 20, 2011

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.

TOPICS
Scripting
490
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Feb 21, 2011 Feb 21, 2011

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 21, 2011 Feb 21, 2011
LATEST

Thanks for reply Loic_aigon

As Marc suggested in discussion, I used

myTable.rows.cells.characters.everyItem().contents.length > 0


But above syntex falls script to infinite loop.

any other help will be appreciated.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines