4 Replies Latest reply on Jun 24, 2015 2:48 PM by freeweel

    Open Old FrameMaker Documents with ExtendScript

    freeweel

      I am trying to open a FrameMaker 5.5 document using scripting and convert it to XML. 

       

      I can open the files in the interactive version, but when I try to open them in FrameMaker 2015 using ExtendScript it just won't open.  No return parameter errors.  Just says not valid document. 

       

      Is there a parameter I can set in the open parameters to allow this?

      Anyone have an example of how to do this?

       

      Paul V

        • 1. Re: Open Old FrameMaker Documents with ExtendScript
          frameexpert Level 4

          Paul, Can you post the code that you are currently using? Thanks. -Rick

          • 2. Re: Open Old FrameMaker Documents with ExtendScript
            freeweel Level 1

            Rick, Here's a simplified version of the code:

             

                 var openParams = GetOpenDefaultParams();

                 var i = GetPropIndex(Constants.FS_MakeVisible, paramType);

                 openParams[i].propVal.ival = 0;

             

                 var path = "D:/MyOldFrameFile.fm";

                 var doc = Open(path, openParams, returnParamOpen);

                 if(doc.ObjectValid() == true)

                 {

                    // If we successfully opened the doc then save as XML and then close

                    // NOTE: Removed this code since it never gets here on the older 5.5 docs....

                 }

                 else

                 {

                    $.writeln("Couldn't open the file: \n" + path + "\n");

                 }

            • 3. Re: Open Old FrameMaker Documents with ExtendScript
              frameexpert Level 4
              function openDocOrBook (filename, structuredApplication, visible) {
                  
                  var i = 0, docOrBook = 0;
              
                  // Get default property list for opening documents.
                  var openProps = GetOpenDefaultParams ();
                  // Get a property list to return any error messages.
                  var retParm = new PropVals ();
              
                  // Set specific open property values to open the document.
                  i=GetPropIndex (openProps,Constants.FS_AlertUserAboutFailure);
                  openProps[i].propVal.ival=false;
                  i=GetPropIndex (openProps,Constants.FS_MakeVisible);
                  openProps[i].propVal.ival=visible;
                  i=GetPropIndex (openProps,Constants.FS_FileIsOldVersion);
                  openProps[i].propVal.ival=Constants.FV_DoOK;
                  i=GetPropIndex (openProps,Constants.FS_FileIsInUse);
                  openProps[i].propVal.ival=Constants.FV_ResetLockAndContinue;
                  i=GetPropIndex (openProps,Constants.FS_FontChangedMetric);
                  openProps[i].propVal.ival=Constants.FV_DoOK;
                  i=GetPropIndex (openProps,Constants.FS_FontNotFoundInCatalog);
                  openProps[i].propVal.ival=Constants.FV_DoOK;
                  i=GetPropIndex (openProps,Constants.FS_FontNotFoundInDoc);
                  openProps[i].propVal.ival=Constants.FV_DoOK;
                  i=GetPropIndex (openProps,Constants.FS_RefFileNotFound);
                  openProps[i].propVal.ival=Constants.FV_AllowAllRefFilesUnFindable;
                  if (structuredApplication !== undefined) {
                      i=GetPropIndex (openProps,Constants.FS_StructuredOpenApplication);
                      openProps[i].propVal.sval=structuredApplication;
                  }
              
                  // Attempt to open the document.
                  docOrBook = Open (filename,openProps,retParm);
              
                  if (docOrBook.ObjectValid () === 1) {
                      // Add a property to the document or book, indicating that the script opened it.
                      docOrBook.openedByScript = true;
                  }
                  else {
                      // If the document can't be open, print the errors to the Console.
                      PrintOpenStatus (retParm);
                  }
              
                  return docOrBook; // Return the document  or book object.
              }
              

               

              This is a general purpose function for opening documents or books. You can call it like this:

               

              var doc = openDocOrBook (filename, structuredApplication, visible);
              

               

              For structured documents, you can pass in a structured application name as the second parameter. For unstructured documents, just use undefined for the second parameter. The "visible" parameter can be 0 (open the document invisibly) or 1 (open the document and make it visible). Please let me know if you have any questions or comments.

               

              Rick

              • 4. Re: Open Old FrameMaker Documents with ExtendScript
                freeweel Level 1

                Thank you Rick...  This did the trick!