Copy link to clipboard
Copied
I have a script that uses character background color to highlight a list of special words throughout a book. When the editor is done checking the words I have another script that changes the background color back to "None." The script works great removing the background color from from both pgfs and tables in individual documents. However, when running it on an entire book, it won't remove the background colors in the tables, even though I'm stepping through each document in the book one by one. It seems to find the tables, because I can get a table count for the book, but it appears it isn't stepping through each table cell by cell. Any suggestions?
function stepThruTables() {
for (n = 1; n <= count; n++) {
totalTbls = 0
doc = SimpleOpen(openDocs[n]);
doc = app.ActiveDoc;
pgf = doc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf;
tblCleaner();
}
}
function tblCleaner() {
while (doc.ObjectValid())
{
tbl = doc.FirstTblInDoc;
if(tbl.ObjectValid() == false) {
$.writeln("Didn't find any tables!");
}
while (tbl.ObjectValid())
{
totalTbls++;
row = tbl.FirstRowInTbl;
while (row.ObjectValid())
{
cell = row.FirstCellInRow;
while (cell.ObjectValid())
{
var cellPgf=cell.FirstPgf;
tr = new TextRange();
textObj = getText(cell); // Calls "getText" function
RemoveTableBkColor (text, textObj);
cell = cell.NextCellInRow;
}
row = row.NextRowInTbl;
}
tbl = tbl.NextTblInDoc;
}
doc = doc.NextOpenDocInSession;
}
totalTbls = totalTbls - 1;
}
char
Copy link to clipboard
Copied
I have no insights on the scripting anomally, but going forward there are other approaches to implementing the highlighting:
Copy link to clipboard
Copied
Thanks for the info Bob. That's an interesting capability I was unaware existed. I'll check it out. That may solve my background color problem for my immediate task. I would still like to get this script figured out as it will be useful for other tasks in which I have to step through all tables in a book. Appreciate any other suggestions.