Skip to main content
Participant
June 8, 2020
Answered

Delete all markers starting with "Part No" and type "Index"

  • June 8, 2020
  • 1 reply
  • 752 views

I want to delete all the Index markers in a framemaker document that are starting with text Part No.

Is this possible with Framemaker scripting?

    This topic has been closed for replies.
    Correct answer frameexpert
    #target framemaker
    
    var doc, marker, nextMarker, regex;
    
    // Set a variable for the active document.
    doc = app.ActiveDoc;
    // Make a regular expression for the text.
    regex = /^Part No\./;
    
    // Process all of the markers in the document.
    marker = doc.FirstMarkerInDoc;
    while (marker.ObjectValid () === 1) {
        nextMarker = marker.NextMarkerInDoc;
        // Make sure it is an Index marker.
        if (marker.MarkerTypeId.Name === "Index") {
            // Check the text.
            if (regex.test (marker.MarkerText) === true) {
                marker.Delete ();
            }
        }
        marker = nextMarker;
    }

    1 reply

    frameexpert
    Community Expert
    frameexpertCommunity ExpertCorrect answer
    Community Expert
    June 8, 2020
    #target framemaker
    
    var doc, marker, nextMarker, regex;
    
    // Set a variable for the active document.
    doc = app.ActiveDoc;
    // Make a regular expression for the text.
    regex = /^Part No\./;
    
    // Process all of the markers in the document.
    marker = doc.FirstMarkerInDoc;
    while (marker.ObjectValid () === 1) {
        nextMarker = marker.NextMarkerInDoc;
        // Make sure it is an Index marker.
        if (marker.MarkerTypeId.Name === "Index") {
            // Check the text.
            if (regex.test (marker.MarkerText) === true) {
                marker.Delete ();
            }
        }
        marker = nextMarker;
    }
    Participant
    June 10, 2020

    Thank you.