• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Remove Background Color From all Tables in Book

Contributor ,
Nov 22, 2022 Nov 22, 2022

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

Views

94

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 23, 2022 Nov 23, 2022

Copy link to clipboard

Copied

I have no insights on the scripting anomally, but going forward there are other approaches to implementing the highlighting:

  • Color Views:
    Use a unique named color, and set it to Invisible for publication.
  • Color Definitions:
    Use a unique named color and set it to white for pub.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 23, 2022 Nov 23, 2022

Copy link to clipboard

Copied

LATEST

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. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines