Is there a way to add text to cells and apply character style in cell
I'm working in InDesign 5 on a Mac.
I'm formating two tables with info that will eventually be combined. I've put together scripts I found on these forums to add the necessary columns, merge rows and fill the merged cells with the correct color, but am having trouble with two remaining tasks.
1. Is it possible to add text to a certain cell?
2. And is it possible to apply a character style to certain cells? (different cells than the ones I need to add text)
I've been playing with this code, but don't know if it's even close . . .
{
table.rows[0].cells[0].insertText ("CS/PS");
}
{
table.rows[0].cells[0].appliedCharacterStyle ("bold");
}
The following are the scripts I've combined so far for the table. . .
// add column
myTable = app.selection[0];
myColumn = myTable.columns[1];
for (a=0; a < 1; a++)
{
myTable.columns.add(LocationOptions.AFTER, myColumn);
}
// merge rows
table = app.selection[0];
if (table.hasOwnProperty("baseline")) table = table.parent;
if (table instanceof Cell) table = table.parent;
if (table instanceof Column) table = table.parent;
if (table instanceof Row) table = table.parent;
if (table instanceof Table)
{
table.rows[0].cells[0].merge (table.rows[0].cells[1]);
}
{
// alternate colors in merged rows
r = table.rows[1];
n = app.activeDocument.swatches.item("orange");
b = app.activeDocument.swatches.item("PANTONE 3005 C");
for (c=0; c<r.cells.length; c++)
{
if (c & 1)
r.cells
else
r.cells
}
}