Well, it seems that my script is only 95% there. While my script finds the target paragraphs and adds a marker, only the first word of each paragraph is selected as the marker text. I really need the script to select the whole paragraph as the marker text. I have tried many combinations, but cannot seem to get the right outcome. Could anybody please point me in the right direction? Script is copied below. Many thanks! var doc = app.ActiveDoc; var flow = doc.MainFlowInDoc; var tframe = flow.FirstTextFrameInFlow; var pgf = tframe.FirstPgf; var target1 = doc.GetNamedObject(Constants.FO_PgfFmt, "*Part no."); var target2 = doc.GetNamedObject(Constants.FO_PgfFmt, "*Parent Bold"); var target3 = doc.GetNamedObject(Constants.FO_PgfFmt, "*Child"); var target4 = doc.GetNamedObject(Constants.FO_PgfFmt, "*Child indent"); var target5 = doc.GetNamedObject(Constants.FO_PgfFmt, "*Child indent 2"); while (pgf.ObjectValid()) { if (pgf.Name == target1.Name) { createMarker (doc, pgf, 0, "Index", ""); } else if (pgf.Name == target2.Name) { createMarker (doc, pgf, 0, "Subject", ""); } else if (pgf.Name == target3.Name) { createMarker (doc, pgf, 0, "Subject", ""); } else if (pgf.Name == target4.Name) { createMarker (doc, pgf, 0, "Subject", ""); } else if (pgf.Name == target5.Name) { createMarker (doc, pgf, 0, "Subject", ""); } pgf = pgf.NextPgfInDoc; } function createMarker(doc, pgf, offset, type, text) { var tLoc = new TextLoc(pgf, offset); var marker = doc.NewAnchoredObject(Constants.FO_Marker, tLoc); var markerType = doc.GetNamedObject(Constants.FO_MarkerType, type); marker.MarkerTypeId = markerType; marker.MarkerText = text; return 1; }
... View more