3 Replies Latest reply on May 21, 2015 6:08 AM by Russ Ward

    Opening Word files from a script

    4everJang Level 3

      I need to open Word files from an Extenscript, and I cannot find the required info in the docs. I did check the FDK documentation and I assume I need to specify a FileTypeHint, but there is no info on the Word ".docx" filter. If anyone has done this before, let me know. The script should be able to do it without any user interaction.



        • 1. Re: Opening Word files from a script
          frameexpert Level 4

          Hi Jang,


          This may help you in a roundabout way: here is a function that saves FrameMaker documents as RTF. The open parameters should be similar. The import strings can be seen in the maker.ini file.


          function saveToRTF (doc, saveName) {
              var params = GetDefaultSaveParams ();
              var returnParams = new PropVals ();
              var i = GetPropIndex (params, Constants.FS_FileType);
              params[i].propVal.ival = Constants.FV_SaveFmtFilter;
              i = GetPropIndex (params, Constants.FS_SaveFileTypeHint);
              params[i].propVal.sval = "0001ADBIRTF ";
              doc.Save (saveName, params, returnParams);
          • 2. Re: Opening Word files from a script
            4everJang Level 3

            Hi Rick,


            I did find the FileTypeHint for the newer Word format - "0001ADBIWORDWIN3"


            I found it by importing a Word doc into a FrameMaker document as text inset, then selecting the text inset and running a script that shows the properties of the inset. That is where the FileTypeHint also shows up. The list of hint strings in the documentation is pretty outdated and mostly concentrates on images.





            • 3. Re: Opening Word files from a script
              Russ Ward Level 4

              Hi Jang,


              Coincidentally, I just had the requirement to save as RTF and I needed this FileTypeHint information as well. Like you, I found the documentation lacking and I also found that the app.ExportFilters property did not seem to work right, in order to discover the filter names. So, I resorted to the FDK to iterate through the FP_ExportFilters and I got a list. Once I applied the RTF filter name, "0001ADBIRTF         Microsoft RTF1.6", it worked fine. Here is the list for you and anyone else that might be searching. This came from FM11:




              Curiously, though, the Word filter name that you discovered is not in the list. So, I think your method of finding it is quite clever indeed.


              Note that I used the RTF name just like FP_ExportFilters reported, with the 9 whitespace characters in between. Rick's post suggests that it might work with just a single space after the main filter name.