Skip navigation
Currently Being Moderated

how to find the tables only placed on pages.

Jun 29, 2012 10:00 PM

Tags: #tables #indesign_cs5

Hi experts,

      I'm finding all the tables in the .indd document (Non XML Indd file.) In that there are some number of tables. And a table in Master page also there. Now I'm trying to get only the tables except the master page. How can I got it?

I used the following code. But it's not working properly.

 

var myTables=app.activeDocument.stories.everyItem().tables;

app.select(myTables[0]);

var myTableCount=myTables.length;

alert(myTableCount);

for(var i=0;i<myTableCount;i++){

var myTableObj=myTables[i];

alert(myTableObj.parent);

try

{

var xxx = myTableObj.parent.parentPage.name;

if(xxx.match("^[0-9]+$"))

{

     alert("Table");

    myTableObj.label="table"+(i+1);

    }

else

{

   alert("Master-Page Table");

    }

}

catch(e)

{

    alert(e.message);

    }

}

 

Always throwing catch loop...

 

Can anyone guide me.................................!

 

Thanks and Regards,

Vel.

 
Replies
  • Currently Being Moderated
    Jun 30, 2012 1:32 AM   in reply to Velprakash

    The parent of a document page is a Spread, that of a master page is a MasterSpread. Therefore:

     

    if (myTable.storyOffset.parentTextFrames[0].parentPage.parent.constructo r.name != 'MasterSpread')

         $.writeln ('Not on a master page);

    else

         $.alert ('On a master page');

     

    This is in CS5 and later. Earlier versions don't have the parentPage property, andthe parenthood of pages is a bit different in those earlier versions.

     

    Peter

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 30, 2012 2:08 AM   in reply to Velprakash

    There's a space in constr uctor (which I managed to put there, sorry). That's probably the problem.

     

    Peter

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 30, 2012 5:02 AM   in reply to Velprakash

    There's no need to select anything. Instead of this:

     

    app.select(v[x]);

    app.selection[0].label = "table"+count;

     

    do this:

     

    v[x].label = "table"+count;

     

    Peter

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 3, 2012 1:45 AM   in reply to Velprakash

    Google is your friend: http://forums.adobe.com/thread/615381

    Dave Saunders's function there works in all versions of InDesign (from CS3 anyway).

     

    Peter

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points