Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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);
}
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Just ran across this thread, which may be very useful in future for work I do. My appreciation to Yatani for the script to get all the filter names. I can see there are a lot of import/export filters that can be used. I tried to check out Rick's "saveToRTF()" function, but I'm missing the GetDefaultSaveParams and GetPropIndex functions to make it work. I'm still clueless on how parameters work, how they are set, and what ones you need to set to make something work. I've yet to run across anything that explains them either...at least something I can understand. I'd like to know more. Any assistance appreciated, as always.
Copy link to clipboard
Copied
The GetDefaultSaveParams and GetPropIndex functions are built into FrameMaker ExtendScript.
Copy link to clipboard
Copied
I must be doing something wrong then. I tried running script below and get error that GetDefaultSaveParams is not a function.
#target framemaker;
var doc = app.ActiveDoc;
var saveName = "C:\\Users\\fight\\Desktop\\NewWordFile\\";
saveToRTF(doc, saveName);
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);
}
Also tried 4everJang's FileTypeHint for the newer Word format - "0001ADBIWORDWIN3" with similar results.
Copy link to clipboard
Copied
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]);
}
}