Hello,
I have the following code. I'm attempting to parse a document and search for specific keywords based on regex. This part is working. I then get the text range for those keywords and highlight the text. This works. What doesn't work is when I try to do the same thing in text that is in a Table Cell.
#target framemaker var doc = app.ActiveDoc; var totalPgfs = 0; var pgf = doc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf; function do_table_work(pgf){ var result = pgf.GetText(Constants.FTI_TblAnchor); var all_text = ''; for (var i = 0; i < result.length; i += 1) { var t_object = result[i].obj; var t_cell = t_object.FirstRowInTbl.FirstCellInRow; while(t_cell.ObjectValid()){ var cell_items = t_cell.GetText(Constants.FTI_String); var tr = new TextRange(); tr.beg.obj = tr.end.obj = pgf; tr.beg.offset = 0; //this is built dynamically tr.end.offset = 7; //this is built dynamically apply_char_format(text_range) t_cell = t_cell.NextCellInTbl; } } } function apply_char_format(text_range, name) { var color = doc.GetNamedColor(name); if (color.ObjectValid()) { var set_val = new TypedVal(); set_val.valType = Constants.FT_Integer; set_val.ival = true; doc.SetTextVal(text_range, Constants.FP_UseBkColor, set_val); set_val.valType = Constants.FT_Id; set_val.obj = color; doc.SetTextVal(text_range, Constants.FP_BkColor, set_val); } else { alert('Color does not exist'); } } while (pgf.ObjectValid()) { do_table_work(pgf); pgf = pgf.NextPgfInFlow; }
The problem is it's not highlighting the text in the table cell like I want it to. If I process the document, and use the following:
var result = pgf.GetText(Constants.FTI_String);
It will highlight the text (with additional code to loop through those results).
Any thoughts on what I'm missing?