Skip to main content
Inspiring
November 11, 2014
Answered

Select table using script

  • November 11, 2014
  • 4 replies
  • 4837 views

Hi,

The below line selected all the tables in the document. I need to select a first table and then next table etc...

var myTable = app.activeDocument.tables.everyItem().getElements();

Anyone help me?

I am in new for scripting. How do i refer this type of InDesign commands while i am writing scripts?

Regards,

Velumani

This topic has been closed for replies.
Correct answer Sajeev Sridharan

Try this,

var myTable = app.activeDocument.stories.everyItem().tables.everyItem().getElements();

alert(myTable.length)//no. of tables in a document

for(var i=0; i<myTable.length; i++)

{

    myTable.select()//selecting each an every table

    alert("Table " + (i+1) + " Selected");

}

Vandy

4 replies

Adobe Expert
September 14, 2021

Hi ru.design,

the code was damaged when this thread was moved from the old Adobe InDesign Scripting forum to the new Adobe InDesign forum. Corrected code:

var myTable = app.activeDocument.stories.everyItem().tables.everyItem().getElements();

alert(myTable.length)//no. of tables in a document

for(var i=0; i<myTable.length; i++)
{
    myTable[i].select()//selecting each an every table
    alert("Table " + (i+1) + " Selected");
};

 

I changed myTable.select() to myTable[i].select()

 

Regards,
Uwe Laubender

( ACP )

ru.design
Participating Frequently
September 14, 2021

Hi Uwe Laubender,

 

thank you kindly for your updated code.

but I still get this error, any ideas what I am doing wrong?

 

Adobe Expert
September 14, 2021

That's not an error. It's just that alert message in the code telling you the number of tables in your document.

Press OK and the next thing should be the first table selected.

 

Regards,
Uwe Laubender

( ACP )

ru.design
Participating Frequently
September 14, 2021

Hi there, I realise that this thread is quite old now but I have just used this in InDesign version 15.0.1.

 

what have I done wrong to get error string: 'myTable.select is not a function'? do I need to add something to the script?

I am not a scripting expert would really appreciate if someone could explain in simple terms 🙂 Thank you

 

ru.design
Participating Frequently
September 14, 2021

FYI: I am trying to run a script that can select all the tables in my InDesign document (approx 750 tables)

brian_p_dts
Brainiac
October 7, 2021

Edit: disregard I see you got answers below.

 

Much code got broken when the forums changed. 

 

Change the offending line to 

myTable[i].select();

Participating Frequently
May 6, 2016

I'm following this forum, what kind of script is this? .vbs or java?

I'm interested to try this.

Thank you!

Michelle

Adobe Expert
May 7, 2016

micheller81371267 wrote:

I'm following this forum, what kind of script is this? .vbs or java?

I'm interested to try this.

Hi Michelle,

this is Adobe ExtendScript (JavaScript).
You are ready to go, if you will save the code as text-only file with a *.jsx suffix.

Uwe

Participating Frequently
May 9, 2016

Hi Uwe,

Thank you, the script helps but I need it more specific to do this job: a table selected and separated from the text frame; cut and pasted on the pasteboard and it will repeat its process depending how many tables there are in the text frame. I'm not that familiar with script, this might give me an idea to start creating on my own. I really appreciate your help

Sajeev SridharanCorrect answer
Brainiac
November 11, 2014

Try this,

var myTable = app.activeDocument.stories.everyItem().tables.everyItem().getElements();

alert(myTable.length)//no. of tables in a document

for(var i=0; i<myTable.length; i++)

{

    myTable.select()//selecting each an every table

    alert("Table " + (i+1) + " Selected");

}

Vandy

VeluVKAuthor
Inspiring
November 13, 2014

Hi Vandy,

Thank you for the script.

Regards,

Velu