Copy link to clipboard
Copied
I want to process all tables in my InDesign document that have the "summary.product" Table Style applied. Currently, I am using the code below, which gets all of the table and then checks each with a loop. But I am wondering if there is a way to get them with a single line.
var tables, count, i;
tables = app.activeDocument.stories.everyItem ().tables.everyItem ().getElements ();
count = tables.length;
for (i = 0; i < count; i += 1) {
if (tables[i].appliedTableStyle.name === "summary.product") {
// Process the table.
}
}
Hi @frameexpert , I don’t think so—if there is a conditional you have use some kind of loop.
If you wanted to change the properties all of the tables in a document you can do something like this:
var tables = app.activeDocument.stories.everyItem ().tables.everyItem ().properties = {appliedTableStyle = "summary.product"};
You could shorten the code with a while statement—something like this:
var t = app.activeDocument.stories.everyItem ().tables.everyItem ().getElements ();
var i = t.leng
...
Copy link to clipboard
Copied
Hi @frameexpert , I don’t think so—if there is a conditional you have use some kind of loop.
If you wanted to change the properties all of the tables in a document you can do something like this:
var tables = app.activeDocument.stories.everyItem ().tables.everyItem ().properties = {appliedTableStyle = "summary.product"};
You could shorten the code with a while statement—something like this:
var t = app.activeDocument.stories.everyItem ().tables.everyItem ().getElements ();
var i = t.length; while (i--) if (t[i].appliedTableStyle.name === "summary.product") alert("Do Something")
Find more inspiration, events, and resources on the new Adobe Community
Explore Now