Skip to main content
DigitalChickster
Inspiring
March 8, 2023
Answered

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

  • March 8, 2023
  • 2 replies
  • 891 views

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

 

 

This topic has been closed for replies.
Correct answer SJRiegel

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.

2 replies

rob day
Community Expert
Community Expert
March 9, 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;
}

  

 

 

 

 

 

After run:

DigitalChickster
Inspiring
March 16, 2023

Thanks! I'll try it! 

SJRiegelCorrect answer
Legend
March 8, 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.

DigitalChickster
Inspiring
March 16, 2023

Thank you! I'll give it a try.

DigitalChickster
Inspiring
March 16, 2023

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