I needed a script that will merge any empty cells in a table in an InDesign document with the cell directly above it. I thought I had it figured out, with this script:
var myDoc = app.activeDocument;
myPage = myDoc.pages;
for (var p=0; myPage.length>p; p++){
try{
var myTable = myPage[p].textFrames.everyItem().tables.everyItem();
if (myTable.constructor.name == 'Table'){
for (var t = myTable.cells.length - 1; t >= 0; t--)
{
if (myTable.cells[t].contents==""){
var w = myTable.columns.length;
myTable.cells[t-w].merge(myTable.cells[t]);
}
}
}
}
catch(e){}
}
which worked great, until I tried it on a document with more than one table on the same page, in which case it does nothing to any of the tables on that page, which is unfortunate, because the tables I need this script for are on the same page.