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

How to make sure all my tables are the same width?

Enthusiast ,
Mar 08, 2023 Mar 08, 2023

Is there an easy way to make sure the overall width of my tables are the same? I know how to do each cell, but that would be tedius to go check that for 42 pages of tables I've created. I was given this document, and the table widths on each page vary. I'd like them to be standard. But I am not seeing how to find the overall width of a table without adding up each width of each cell. 

Thanks!

 

Julie

 

 

TOPICS
How to
807
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 , Mar 08, 2023 Mar 08, 2023

If the column widths are intended to be the same in all of the tables, you could use the script from this page to save the column widths from one table, and apply them to other tables that share the same Table Style. 

It's not entirely automatic; you have to select each table and then apply the widths, but it is faster than manually checking and adjusting every cell in every table.

Translate
Community Expert ,
Mar 08, 2023 Mar 08, 2023

If the column widths are intended to be the same in all of the tables, you could use the script from this page to save the column widths from one table, and apply them to other tables that share the same Table Style. 

It's not entirely automatic; you have to select each table and then apply the widths, but it is faster than manually checking and adjusting every cell in every table.

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
Enthusiast ,
Mar 16, 2023 Mar 16, 2023

Thank you! I'll give it a try.

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
Enthusiast ,
Mar 16, 2023 Mar 16, 2023
LATEST

I finally had time to figure this out. And it worked perfectly. Thank you! 

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 ,
Mar 09, 2023 Mar 09, 2023

Hi Julie, Try this script, which asks you for a cell width and sets all of the table cells:

 

 

var x;
makeDialog();
function makeDialog(){
    var d = app.dialogs.add({name:"Adjust Table Cells", canCancel:true});
    with(d.dialogColumns.add()){
        staticTexts.add({staticLabel:"Table Cell Widths:", staticAlignment:StaticAlignmentOptions.LEFT_ALIGN, minWidth: 150});
        x = measurementEditboxes.add({editUnits:MeasurementUnits.INCHES, editValue:72, minWidth:90});
    }
    if(d.show() == true){
        x = x.editValue;
        adjustTable()
        d.destroy();
	}
}


function adjustTable(){
    app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;
    var t = app.documents[0].stories.everyItem().tables.everyItem().cells.everyItem().getElements()
    if (t.length > 0) {
        for (var i = 0; i < t.length; i++){
            t[i].width = x
        }; 
    } else {
        alert("Document has no tables")
    } 
    app.scriptPreferences.measurementUnit = AutoEnum.AUTO_VALUE;
}

  

 

 

 

Screen Shot 15.png

 

 

After run:

Screen Shot 16.png

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
Enthusiast ,
Mar 16, 2023 Mar 16, 2023

Thanks! I'll try it! 

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