Skip navigation
Currently Being Moderated

Script to add markers to text by paragraph format

Jul 31, 2012 7:12 PM

Tags: #framemaker10 #extendscript

With previous versions of Framemaker, I had a FrameScript which would loop through my document and add a marker to text based on the paragraph format applied. The marker text would be the selected paragraph.


I am now trying to recreate this in Extendscript for use in Framemaker 10 and am completely stumped.


I have no doubt that my script (copied below) is completely off-track, but I wondered if anybody would be able to help point me in the direction of my many mistakes.


Basically, I want the script to find all paragraphs with the "*Part no." format applied, make that text the text range and then apply a marker to that range. A bit of research has shown that I probably need to create a list of paragraph formats, but I believe that I have far more problems than just that.


var pgfFmt1 = flow.GetNamedPgfFmt (*Part no.);

while (pgfFmt1.ObjectValid())  


    function createMarker (doc, pgf, offset, type, text)    {

        var tRange, marker;

        tRange = pgfFmt1.TextRange;

        marker = doc.NewAnchoredObject(Constants.FO_Marker, tRange);

        marker.MarkerType = type;

        marker.MarkerText = text;

        return 1;


createMarker (doc, pgf, 0, "Index", 0);

Many thanks in advance to anyone who is able to offer me some pointers!

  • Currently Being Moderated
    Aug 1, 2012 2:07 AM   in reply to mrsjackharkness

    If you have an working FrameScript you only have to bring that syntax to ExtendScript and particular a little bit more ;-)

    But there is your algorithm, to find paragraphs... and there are hints how to use the FrameMaker object model


    Searching for paragraph in a document works like this pseudo code:


    var pgf = app.ActiveDoc.FirstParagraphInDoc;

    while (pgf.ObjectIsValid()


         if (pgf.Name != 'Partno')


              pgf = pgf.NextParagraphInDoc;




         //do code for setting markers


         pgf = pgf.NextParagraphInDoc;


    Mark as:
  • Currently Being Moderated
    Aug 5, 2012 4:46 PM   in reply to mrsjackharkness

    You can use the following function to get the text from a FrameMaker paragraph.


    function getText(textObj) {


      var objText = "";

      // Get a list of strings from the object.

      var textItems = textObj.GetText(Constants.FTI_String);

      // Concatenate the strings.

      for (var i = 0; i < textItems.len; i += 1) {

        objText += (textItems[i].sdata);



      return objText;



    Once you add it to your script, you can modify each call to createMarker to something like this:


    createMarker (doc, pgf, 0, "Subject", getText(pgf));


    --Rick Quatro

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points