Copy link to clipboard
Copied
Is it possible to select all cells of a certain width of 130pt and change to a width of 145pt using a script
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...
Copy link to clipboard
Copied
//~ 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;
}
}
}
}
Copy link to clipboard
Copied
Thanks
There is an error when executing the script
Copy link to clipboard
Copied
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');
Copy link to clipboard
Copied
Thanks
Find more inspiration, events, and resources on the new Adobe Community
Explore Now