Skip to main content
4everJang
Legend
May 14, 2015
Question

Opening Word files from a script

  • May 14, 2015
  • 2 replies
  • 1013 views

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.

Jang

This topic has been closed for replies.

2 replies

Participating Frequently
July 24, 2023

Hi Jang,
I wrote a script to get the required list in ESTK.

$.writeln ("===== ImportFilters =====");
f_showFilters (Constants.FP_ImportFilters);
$.writeln ("===== ExportFilters =====");
f_showFilters (Constants.FP_ExportFilters);

function f_showFilters (p){
	var params = app.GetProps();
	var i = GetPropIndex (params, p);
	var ssval = params[i].propVal.ssval;
	for (var j=0;j<ssval.length;j++){
		$.writeln (ssval[j]);
	}
}
frameexpert
Community Expert
Community Expert
May 14, 2015

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.propVal.ival = Constants.FV_SaveFmtFilter;

    i = GetPropIndex (params, Constants.FS_SaveFileTypeHint);

    params.propVal.sval = "0001ADBIRTF ";

    doc.Save (saveName, params, returnParams);

}

4everJang
4everJangAuthor
Legend
May 21, 2015

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.

Ciao

Jang

Legend
May 21, 2015

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:

http://www.weststreetconsulting.com/misc/filetypehintfilters.htm

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.

Russ