Skip to main content
January 20, 2021
Question

How do I create a new FM document using Extendscript?

  • January 20, 2021
  • 1 reply
  • 238 views

How do I create a new document in FrameMaker using Extendscript without prompting the user? I'd like to duplicate the functionality of the user doing "File" -> "New..." -> "New Document", then selecting the "Portrait" button.

 

I think I either need to figure out how to programatically locate the "Portrait" template file and pass that as the filename, or maybe there is a open parameter I can specify that says to use the Portrait template.

 

Here is the code I have so far:

 

var filename = undefined;
var oParams = GetOpenDefaultParams();
var rParams = new PropVals();

oParams[GetPropIndex(oParams, Constants.FS_NewDoc     )].propVal.ival = true;
oParams[GetPropIndex(oParams, Constants.FS_ShowBrowser)].propVal.ival = false;

var doc = Open(filename, oParams, rParams);
if (doc.ObjectValid() == false)
    PrintPropVals(rParams);

// PropVals
// --------
//     prop num = 1 String value = 
//     prop num = 2 Integer value = 0
//     prop num = 3 Unsigned Integer values are:
//     0
//     0
//     8
//     0
//     0

 

This topic has been closed for replies.

1 reply

January 20, 2021

I found this question/answer (Newbie Question #1: Creating New Document ) after posting my question via the Related Conversations list. It's good enough for what I need, but it would be interesting to see if there is a more idiomatic way of creating a new portrait or landscape document. I don't know if this is possible, but if the default portrait or landscape template was changed, this would not produce the desired results.

frameexpert
Community Expert
Community Expert
January 21, 2021

Hi. If this is a concern, you may want to make your own template and store it in convenient folder. That way, you can create a new document based on the template and you wan't have to specify all of the individual parameters. I don't have time to post code to do it, but it looks like you have a pretty good start on it.