Monday, March 12, 2012

Saving FM Binary in Old Version

If you have ever needed to revert FrameMaker files to an older version, the following script does so automatically. It works on the active document but you could convert it to work on a book or a directory of files.

The key to the script is the Save() method which allows you to set the file type as desired. I have chosen FrameMaker 9 (FV_SaveFmtBinary90) but you can  go as far back as FrameMaker 6 (FV_SaveFmtBinary60).

I chose not to change the file name. I end the script by closing the FM 10 version of the file without saving it. The FM9 version is already on disk.

var doc,  name, saveParams, i;

doc = app.ActiveDoc;
name = doc.Name;

saveParams = GetSaveDefaultParams();
returnParams = new PropVals();
i = GetPropIndex(saveParams, Constants.FS_FileType);
saveParams[i].propVal.ival =Constants.FV_SaveFmtBinary90;
doc.Save(name, saveParams, returnParams);
doc.Close(Constants.FF_CLOSE_MODIFIED);

After running the script, I opened the test file just to convince myself this really works.


4 comments:

  1. Hi Debra,

    As far as I know, the FV_SaveFmtBinary60/70 function does not work in Extendscript. I tried running a script that is supposed to save a file as FM7, but it did nothing. When I changed FV_SaveFmtBinary70 to FV_SaveFmtBinary80, it did work.

    Kind regards,
    Roman

    ReplyDelete
    Replies
    1. I confess that I did not test these but relied on the documentation.

      Delete
    2. Hi Debra,

      First of all, thank you for your response! I wish it did work. Sometimes, I need to save files as FM7, so the only way to do it is to save them as MIF7.0, which is far from being ideal...

      In any case, thank you for writing these great articles and for sharing them with other FM users!

      My best wishes,
      Roman

      Delete
    3. You can open the MIF and save as binary using the 7.0 FDK. But that is a whole different kettle of fish. Best of luck with your project.

      Delete