ExtendScript of the Week: Import and Export Variables


As part of the series ‘ExtendScript of the week’, we are providing an ExtendScript to export a list of User Variables in a FrameMaker Book. The list will also show the status that whether the user variables is used or not. After the list has been generated, you can modify the definition of the user variables in the table and the table can be imported back to the book. This will help modifying and deleting user variables at the book level.

Download the zip file from ImportExportVariables.

About the Script

  • It contains 3 scripts, menu.jsx which loads the menu items and calls functions to handle the workflow, importExport.jsx which is used to import/export list of user variables and utils.jsx that has several utility functions. It also contains a template document, BookReportTemplate, which is used for exporting user variables
  • 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 import functionality traverses through the book, opens the book component file silently and extracts the user variables information. File is then closed silently without saving. A book report (table) containing a list of all user variables in the book is generated
  • The export functionality traverses the report document to locate a table and name of the source book. The information of each user variable is extracted from the table and the information is updated in the document (in source book) if required. To delete a particular variable, clear the corresponding “definition” cell in the table (i.e. set the contents of the cell to empty). Any document not found in the scope of the source book is left as is. Also, the modified documents in this process will not be closed/saved but will be left open visibly in FrameMaker and user can have a look at the console window for the list of changes made

Steps to use this ExtendScript

  • Unzip the contents of the attached .zip file to the FrameMaker startup folder:
    "C:\Program Files\Adobe\AdobeFrameMaker11\startup"
  • Launch FrameMaker
  • For export functionality, open any book for which you want to export list of user variables
  • With focus on book, go to “File > Utilities > Export User Variables”
  • A FrameMaker document report containing the list of user variables will be generated
  • For import functionality, modify the report generated from the export functionality to update/delete any user variable
  • With focus on the report document, go to “File > Utilities > Import User Variables”
  • An alert will come, asking for your confirmation. If you click Cancel, the operation will be aborted
  • If you wish to continue by pressing OK, the script will run and update the documents (if required)

Hope this simple automation will help to reduce your manual efforts and provide further insights into ExtendScript usage.

Saurabh Agrawal

FrameMaker Engineering Team

(Resources: ImportExportVariables)

ExtendScript, FrameMaker, Products

Posted on 12-05-2011


  • By Isha - 10:42 AM on August 19, 2016   Reply

    Hi Saurabh,

    I am using FM10. I have saved files after extracting to the location mentioned. After restarting FM, I am unable to find “File > Utilities > Export User Variables”.
    Is this applicable only to FM11?


    • By saurabh - 7:13 AM on August 24, 2016   Reply

      Hi Isha,

      I tried it myself in FM10. I extracted the files to the location “C:\Program Files (x86)\Adobe\AdobeFrameMaker10\startup” and it is working correctly. Are you sure you extracted to the correct location?
      Also, you need to restart FM after copying the files.

      Meanwhile, we have published a new version. Please check our blog post: http://blogs.adobe.com/techcomm/2016/01/framemaker-9-to-2015-compare.html

  • By john - 9:52 AM on May 30, 2013   Reply

    The script fails because of the SimpleNewDoc command and its behavior, i.e. it does not open a document, when the template file has a problem (such as missing fonts). Correct the utils.jsx file, function createReportDoc(book) to:

    /*create report doc from the template and assign it a label*/
    function createReportDoc(book)
    var outputDoc = SimpleNewDoc (File($.fileName).parent.fsName + “\” + “BookReportTemplate”, 0);
    /* Start of new code */
    if(!outputDoc || !outputDoc.ObjectValid())
    alert(“In the following ‘New’ dialog select the file ” + File($.fileName).parent.fsName + “\” + “BookReportTemplate as Template and click [New]!” )
    var outputDoc = SimpleNewDoc (File($.fileName).parent.fsName + “\” + “BookReportTemplate”, 1);
    /* End of new code */
    if(!outputDoc || !outputDoc.ObjectValid())
    alert(“Could not open template report document “);
    outputDoc.Label = “Variables” + “: ” + File(book.Name).name + “.fm”;

    return outputDoc;

    Alternatively, open file BookReportTemplate once, make a change and redo the change, and save the file with the option, to eliminate all missing fonts.


  • By DDuane - 8:33 PM on May 23, 2013   Reply

    When attempting to use the script based on the provided instructions, it fails with a script alerted that states the template report document could not be opened.

    • By john - 9:53 AM on May 30, 2013   Reply

      See may comment above


      • By DDuane - 10:41 PM on May 30, 2013   Reply


        Thank you so much. I updated the script as you indicated and it worked perfectly.


        • By DDuane - 6:08 PM on May 31, 2013   Reply

          A caveat to anyone else wanting to use this script. Now that I have it working (thanks to John), I am at a total loss as to why the BookReportTemplate file is set to UKEnglish, and the FormatA table settings used for the variable report file are in French. No wonder the original script had issues.

          • By john - 8:40 PM on August 7, 2013  

            Hi Duane, the problem is not the language assigned to the file/table. The problem is, as I realized meanwhile, that the template file was saved as FM 10 file (the script is from times when FM 10 was the current version). The SimpleNewDoc command however is not used in such a way, that it could handle a template file from previous FM versions, so you run into problems using the script in FM 11. By changing the last parameter of SimpleNewDoc from 0 to 1, the command does not fail to open the template altogether but provides you with the file open dialog allowing to select the template file manually.

  • […] (Dies ist eine gekürzte Fassung des Adobe-Beitrags »Import and Export Variables)«) […]

Join the discussion