I have a document that is frequently modified with a lot of tables. There are two table cell styles used in the document. One is used when a cell is empty; the other is used when it is not empty.
Right now, I apply the "has data" style to all cells, then manually apply the "disabled" style to all the cells that are empty. Typically the tables are updated by deleting their contents and copy/pasting the data from Excel.
What I'd like to happen is that the cell style is applied automatically, depending on whether it has content or not. It doesn't look like there's a "Grep table cell style" feature in CS5. Is there another way to do this?
I suspect this could be scripted, but I'm having trouble understanding how to do that. Below is my non-working attempt:
// This doesn't work
var mT = app.selection[0].tables[0];
var len = mT.cells.length;
while (len-->0) {
if (mT.cells[len].contents == "") {
mT.cells[len].applyCellStyle("Disabled cell");
}
else {
mT.cells[len].applyCellStyle("Has data");
}
}