Reply To: Can you help me adapt this table script?

#113667
Peter Kahrel
Member

It’s not so clear what’s going wrong. And that script is rather inefficient — here is another approach:

var i, j, cells;
// Get all the rows in the document
var rows = app.documents[0].stories.everyItem().tables.everyItem().rows.everyItem().getElements();
for (i = 0; i < rows.length; i++) {
	// Get all the cells in a row
	cells = rows[i].cells.everyItem().getElements();
	for (j = cells.length-1; j >= 1; j--) {
		if (cells[j-1].contents == '') {
			cells[j-1].merge (cells[j]);
		}
	}
}

P.

This article was last modified on January 16, 2019

Comments (0)

Loading comments...