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

Where can I sort out the representation of the parts of the document structure?

Guide ,
Jun 24, 2025 Jun 24, 2025

For example,  the following seems to represent all the tables in the document. 
If I want to change only the width of all the tables in the current selected textFrame, how do I change it.
Confused again.

main();
function main() {    
var myTables = app.activeDocument.textFrames.everyItem().tables.everyItem().getElements(),
        len = myTables.length,
        i, col, parentWidth, factor;
    for (i = 0; i < len; i++) {
        // Get the width of the text box that the form belongs to and divide it by the width of the form to get the zoom ratio.
        parentWidth = myTables[i].parent.geometricBounds[3] - myTables[i].parent.geometricBounds[1];
        factor = parentWidth / myTables[i].width;
        //Nest a for-loop that applies scaling to each column width 
        for (col = 0; col < myTables[i].columns.length; col++) {
            myTables[i].columns[col].width *= factor;
        }
    }
}

And then there are these, which have never made sense.

Please advise, thank you.

 

All open documents.
Currently open document.
The currently selected textFrame.
All text boxes in the current document.
All tables in the current document.
The currently selected textFrame (article?) All tables in the current document.

The currently selected table.
The currently selected row.
All cells in the currently selected row.
The currently selected cell.
The currently selected row.

All the frames in the current text.
The current textFrame(article?) All the charts in the current text box (article?).
The currently selected frame.

 

TOPICS
Scripting
220
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

correct answers 1 Correct answer

Community Expert , Jun 25, 2025 Jun 25, 2025

@dublove said: "… If I want to change only the width of all the tables in the current selected textFrame, how do I change it."

 

Hi @dublove ,

you could address the texts[0] text object of the text frame and look after all tables and write  them to an array you could later loop to change the width:

var selectedTextFrame = app.selection[0];
var tablesOfTextFrameArray = selectedTextFrame.texts[0].tables.everyItem().getElements();

alert( "Number of tables:" +"\r"+ tablesOfTextFrameArray.length );

...
Translate
Engaged ,
Jun 24, 2025 Jun 24, 2025

You should be able to change "activeDocument.textFrames" to "selection" and get what you want as long as that text frame with the table is selected.

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
Guide ,
Jun 24, 2025 Jun 24, 2025

Hi John D Herzog

Is there a specific program?
I'd actually prefer to know how these codes below are represented.
Thank you very much.

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
Community Expert ,
Jun 25, 2025 Jun 25, 2025
LATEST

@dublove said: "… If I want to change only the width of all the tables in the current selected textFrame, how do I change it."

 

Hi @dublove ,

you could address the texts[0] text object of the text frame and look after all tables and write  them to an array you could later loop to change the width:

var selectedTextFrame = app.selection[0];
var tablesOfTextFrameArray = selectedTextFrame.texts[0].tables.everyItem().getElements();

alert( "Number of tables:" +"\r"+ tablesOfTextFrameArray.length );

 

Or you could address them all directly to change the width of the tables or to change the width of an individual column:

var selectedTextFrame = app.selection[0];
selectedTextFrame.texts[0].tables.everyItem().width = "200 mm";

 

See DOM documentation, tables and columns have a width property:

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Table.html

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Column.html

 

But be aware that tables in overset text will not change.

Ran the script snippet above that uses the width property of the table object and set it to "200 mm":

 

Screenshot 1 where there are two tables visible and one in overset text of different widths:

Bildschirmfoto 2025-06-25 um 08.49.22.png

 

After running the script the two visible table's width is now 200 mm:

Bildschirmfoto 2025-06-25 um 08.50.49.png

 

When I change now the height of the text frame so that the third table in overset text is now visible, one can see that it has its original width:

Bildschirmfoto 2025-06-25 um 08.51.01.png

We could try to modify the code a bit to get all tables of the parent story of the selected text frame:

var selectedTextFrame = app.selection[0];
selectedTextFrame.parentStory.texts[0].tables.everyItem().width = "200 mm";

 

The final result is that all tables, also the one in overset text, changed the width:

Bildschirmfoto 2025-06-25 um 08.58.49.png

 

Regards,
Uwe Laubender
( Adobe Community Expert )

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