ExtendScript of the Week: Find/Change Cross Reference Formats / Conditional Tags / Variables


This week in “Extend Script of the Week” initiative we will showcase an extend script which will Find/Change Cross-Reference Formats (aka “XREF Formats), Conditional Tags and Variables on the Body page of a FrameMaker document. This script demonstrates how to use ExtendScript to traverse a document, find Xrefs/Conditional Tags/Variables and then change them or delete them.

Information about the Scripts

  • The zip contains seven ExtendScripts:

    • ChangeFormatMenu.jsx loads the menu and calls the function to execute the work flow.

    • ChangeConditionalFormat.jsx is used to change the conditional tag.

    • ChangeVariable.jsx is used to change the variable.

    • ChangeXrefFormat.jsx is used to change the format of the XRef.

    • ChangeFormatUtils.jsx contains various utilty functions.

    • ChangeFormatUI.jsx prepares the UI to be launched in FM.

    • BookIterator.jsx is used to iterate over the book.

  • The script works on FM/MIF, nested books and its components as well as on the hierarchical components.

  • Any XML file, dita or map which is a part of the book is left untouched.

  • The script will pick up the format/variable/tag from the document or the first non generated component of book.

  • If run on a book, all unopened components will be opened silently and will be modified, saved and closed without asking. All opened components will be modified and left visible.

  • User has an option to include System Variables, by default it has been excluded as it makes the list quite long.

  • User also has an option to delete the conditional tag/variable/xref format which was replaced after the changes are made.

  • At the end the user will be notified about the number of changes made in the document.

Steps to Install

  • Download the zip file from ChangeFormat.

  • Unzip the files and copy “ChangeFormatMenu.jsx” and “ChangeFormat” folder in startup folder located at “C:\Program Files\Adobe\AdobeFrameMaker10\startup\”

How to use the Script

  • Launch FrameMaker

  • Open a Book File or FM/MIF File eg : Doc1_10.fm

  • Run Change Formats from “File -> Utilities -> Change Formats…

  • This will run the script and ask you for inputs for find/change.

  • Click on the radio button to choose the object you want to change.

    FrameMaker ExtendScript – Find/Change Cross-Reference Formats, Variable Formats, Conditional Tags

  • Choose the value to be changed in ‘Find’ dropdown.

  • Choose the value to be applied in ‘Replace With’ dropdown.

  • Click on Change button.

    FrameMaker ExtendScript – Find/Change Cross-Reference Formats, Variable Formats, Conditional Tags


I hope this will prove useful to many folks and you can add extra functionality as per your requirements to these scripts to make it even more powerful

(Resources: ChangeFormats)

ExtendScript, FrameMaker, Products
Bharat Prakash

Posted on 11-23-2011


  • […] couple of years back, we published the free ExtendScript “Change Formats”. The script made it possible find and change Variables, Cross-Reference Formats and […]

  • By Isha - 5:30 AM on July 27, 2016   Reply


    I am new to scripting. I am using extend script. I need a script for fixing cross references in my document/book. I am using unstructured Frame Maker version 10.

    • By Isha - 5:07 PM on August 21, 2016   Reply

      Hi Bharat,

      Can you please provide some guidance on automating (using extendscript) ‘fixing broken cross reference’ for both within the chapter and in the book.


      • By Stefan Gentz - 8:47 AM on August 22, 2016   Reply

        Hi Isha,

        if a cross-reference is broken it means, that the “destination” (the paragraph etc. where the cross-reference is pointing to), does no longer exist / cannot be found. There is a myriad of possibilities why this can happen: An author might have deleted the target destination in the text, or the whole file might have been deleted, or renamed, or is on an inaccessible network file, or files were moved around on the hard drive, or …

        Unfortunately, there is no secret “Fix all my problems” line of code in ExtendScript 😉
        You will have to dig a little bit deeper into it: Why are the cross-references broken? What is the reason? And then think about how to solve that. If there is a clear “pattern” on all your broken cross-references, it might be possible to write code to fix that. The best way will be to write a post in the Adobe Community “FrameMaker Scripting” forum: https://forums.adobe.com/community/framemaker/extendscript?view=overview


  • By Stefan Gentz - 1:25 PM on March 9, 2016   Reply

    Meanwhile, we have published a new version, that also supports find/change for Paragraph, Character and Table Styles:
    Please check our latest blog post: https://blogs.adobe.com/techcomm/2016/03/framemaker-super-find-change.html

  • By mickeymammoth - 10:24 PM on March 25, 2014   Reply

    Used this on FM11 to change all uses of an xref format. But am having mixed results. If no files in the book are open, then the list if xrefs just shows one entry: TemplateName. If I open a file, it finds actual format names. But when I run the utility, it won’t find anything. Or sometimes it does find some. Every time I run it on the same book it varies. The first time, it found tons, and I thought it was done. But it missed a lot. I’m not really sure it did change anything now.

  • By Mushhood Zaheer - 9:16 AM on July 31, 2012   Reply

    Hi I tried running this script as you stated above, but FM10 throws the following console error: 
    Script Error : Error Message      : null is not an objectScript, Line#   : C:Program Files (x86)AdobeAdobeFrameMaker10startupChangeFormatChangeFormatUI.jsx,  81

    This seems to point to the following line of code in ChangeFormatUI.jsx:


    Is it okay to declare varbl as:

    var varbl = new Object();


  • By Roman - 8:51 AM on February 21, 2012   Reply

    Hi Bharat,

    Could you please share the fix with others?

    Kind regards,

    • By bharatp - 9:02 AM on February 21, 2012   Reply

      Hi Roman,

      I have uploaded the Latest zip containing the fixes. Kindly download these files from ‘Resources’.


      1) Problem handling the flow for changing para tags
      2) There was an extra check for checking system variables . This should solve of FM freezing for some folks.
      3) Previously the script did not work on hidden tags but now it does

      Bharat Prakash
      FrameMaker Engineering

  • […] (Dies ist eine gekürzte Fassung des Adobe-Beitrags »Find/Change (XRef Format/Conditional Tag/Variable)«) […]

  • By Roman - 3:50 PM on December 5, 2011   Reply


    For some reason, it does not work for me. When I run the script, Framemaker freezes. BTW, I fixed the var NewCommand = DefineCommand.

    • By Anh Gauthier - 3:44 PM on January 31, 2012   Reply

      Same here – FM freezes when I try to use the menu option.

      • By Bharat Prakash - 3:50 PM on January 31, 2012   Reply

        Hi Anh,

        Thanks for using the script. Kindly send me some sample files so that i can isolate the issue.

        Bharat Prakash(bharatp@adobe.com)
        FrameMaker Engineering

        • By Anh Gauthier - 2:03 AM on February 1, 2012   Reply

          Thanks for the response. I will prep a file and email you.

          • By Bharat Prakash - 10:17 AM on February 1, 2012  

            Hi Anh,

            I have fixed the issue and mailed you the updated scripts. Kindly let me know if there are any more issue.

            Bharat Prakash(bharatp@adobe.com)
            FrameMaker Engineering

  • By Mike Wickham - 6:29 PM on November 28, 2011   Reply

    I have found a bug with this script. When installed, I can no longer type a lowercase letter “u”. Removing the script returns my ability to insert the letter into text.

    • By Bharat Prakash - 6:15 AM on November 29, 2011   Reply

      Hi Mike ,

      Thanks for pointing it out. Kindly replace the following statement in ChangeFormatMenu.jsx and it should take care of the problem.

      Original :: var NewCommand = DefineCommand(1,”Change Formats…”,”Change Formats…”)

      New :: var NewCommand = DefineCommand(1,”Change Formats…”,”Change Formats…”,””)

      • By Mike Wickham - 12:43 AM on November 30, 2011   Reply

        That seems to have fixed it. Thanks!

  • By bharatp - 9:53 AM on November 23, 2011   Reply

    Hi Wim,

    Thanks for the comment. I have not come across this issue.
    Changing conditional tags in structured FM might lead to issues sometimes ,but changing Xref format/Variable should not be a problem.
    Could you send me a sample file on which you facing the issue. My email is bharatp@adobe.com.

    Bharat Prakash

  • By Wim Hooghwinkel - 8:46 AM on November 23, 2011   Reply


    should the script work on structured fm files? If I try that, FM freezes.

Reply to Stefan Gentz