Copy link to clipboard
Copied
I'm trying to script a pretty involved operation on multiple, selected text frames (but not all text frames in the doc), and so I'm taking it step by step. The question I'll ask for now is just the first part and I have been unable to find a script or script discussion that really addresses what I want to do. (I have found lots of documentation on how to get 1 table, or ALL the doc's tables... but that's not what I'm looking for....)
How can I select multiple text frames, some of which have a table and some that don't have a table, and gather up just the tables and put them in an array? So that I can work with just those table objects further?
Thanks for any suggestions or tips to get me going down the right path.
Hi Andy,
You could try the following with selection of some textframes on the document run the following code
var tb = [] //This is the array that will contain the tables within the selected textframes
for(var a = 0; a< app.selection.length; a++)
{
if("tables" in app.selection && app.selection.tables.length)
tb.push(app.selection.tables.everyItem())
}
P.S. :- This will just find the first level tables and not nested tables
-Manan
Copy link to clipboard
Copied
Hi Andy,
You could try the following with selection of some textframes on the document run the following code
var tb = [] //This is the array that will contain the tables within the selected textframes
for(var a = 0; a< app.selection.length; a++)
{
if("tables" in app.selection && app.selection.tables.length)
tb.push(app.selection.tables.everyItem())
}
P.S. :- This will just find the first level tables and not nested tables
-Manan
Copy link to clipboard
Copied
For obtaining table within tables we could use the text search. Sample code mentioned below
app.findTextPreferences = app.changeTextPreferences = null;
app.findTextPreferences.findWhat = "<0016>";
var tb = []
try{
for(var a = 0; a< app.selection.length; a++)
{
var f = app.selection.findText()
for(var i = 0; i < f.length; i++)
tb.push(f.tables.everyItem());
}
}catch(e){}
app.findTextPreferences = app.changeTextPreferences = null;
-Manan
Copy link to clipboard
Copied
Thank you Manan! I will give these a try and let you know how they work.
Copy link to clipboard
Copied
"<0016>" a number meaning table? Are there more of these magic numbers?
Copy link to clipboard
Copied
Manan, this works as I requested. I now have a variable with my table objects. Thanks! (And now on to figuring out how to do with code what I want to do with those tables
)
Find more inspiration, events, and resources on the new Adobe Community
Explore Now