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

Script to select cells of a certain width

Engaged ,
Nov 16, 2025 Nov 16, 2025

Is it possible to select all cells of a certain width of 130pt and change to a width of 145pt using a script

TOPICS
How to , Scripting
128
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 , Nov 16, 2025 Nov 16, 2025

Hi @Summayah5FC7 here's my approach, similar to @virender_CTS but a little different.

- Mark

 

/**
 * @file Find Change Column Width.js
 * 
 * @author m1b
 * @version 2025-11-17
 * @discussion https://community.adobe.com/t5/indesign-discussions/script-to-select-cells-of-a-certain-width/m-p/15593746
 */
function main() {

    // edit these values to suit your needs
    const FIND_COLUMN_WIDTH = 130; // points
    const CHANGE_COLUMN_WIDTH = 145; // points
    const FIND_THRESHOLD = 0.01;

    app
...
Translate
Engaged ,
Nov 16, 2025 Nov 16, 2025

//~ Is it possible to select all cells of a certain width of 130pt and change to a width of 145pt using a script

var myDoc = app.activeDocument;
myDoc.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.POINTS;
myDoc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.POINTS;
var allStories = myDoc.stories;
for(var s = 0; s < allStories.length; s++){
var myStory = allStories[s];
var allTables = myStory.tables;
for(var t = 0; t < allTables.length; t++){
var myTable = allTables[t];
var allCells = myTable.cells;
for(var c = 0; c < allCells.length; c++){
var myCell = allCells[c];
if(myCell.width == 130){
myCell.width = 145;
}
}
}
}

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
Engaged ,
Nov 16, 2025 Nov 16, 2025

Thanks

 

There is an error when executing the scriptScreenshot 2025-11-16 at 15.06.11.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
Community Expert ,
Nov 16, 2025 Nov 16, 2025

Hi @Summayah5FC7 here's my approach, similar to @virender_CTS but a little different.

- Mark

 

/**
 * @file Find Change Column Width.js
 * 
 * @author m1b
 * @version 2025-11-17
 * @discussion https://community.adobe.com/t5/indesign-discussions/script-to-select-cells-of-a-certain-width/m-p/15593746
 */
function main() {

    // edit these values to suit your needs
    const FIND_COLUMN_WIDTH = 130; // points
    const CHANGE_COLUMN_WIDTH = 145; // points
    const FIND_THRESHOLD = 0.01;

    app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;

    var doc = app.activeDocument;
    var columns = doc.stories.everyItem().tables.everyItem().columns.everyItem().getElements();
    var counter = 0;

    for (var i = columns.length - 1; i >= 0; i--) {

        var column = columns[i];

        if (Math.abs(column.width - FIND_COLUMN_WIDTH) > FIND_THRESHOLD)
            continue;

        column.width = CHANGE_COLUMN_WIDTH;
        counter++;

    }

    alert('Changed  ' + counter + ' column widths.');

};
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Find Change Column Width');
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
Engaged ,
Nov 16, 2025 Nov 16, 2025
LATEST

Thanks

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