Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

OpenDocuments.CreateNewDocument Method

Last modified: May 30, 2008

Applies to: SharePoint Foundation 2010

Creates a document based on the specified document template.

expression.CreateNewDocument(bstrTemplateLocation, bstrDefaultSaveLocation)


An expression that returns an OpenDocuments Control object.


A string that contains the URL of the document template from which the document is created, or the programmatic identifier (progID) of the application to invoke when creating the document.


A string that contains the path that specifies a suggested default location for saving the new document.

true if the document creation succeeds; otherwise false.

The following example uses the CreateNewDocument method to create a document. The example assumes the existence of a form named frmCreateDoc that has two input boxes, CreateFileType and FileSaveLoc.

<SCRIPT language="JavaScript">
function RefreshOnFocus()
   window.location.href = window.location;

function CreateDoc()
   NewDocumentButton = new ActiveXObject("SharePoint.OpenDocuments.2");

   if (NewDocumentButton)
      var strFileType = document.frmCreateDoc.CreateFileType.value;
      var strSaveLoc = document.frmCreateDoc.FileSaveLoc.value;

      if (NewDocumentButton.CreateNewDocument(strFileType, strSaveLoc))
         window.onfocus = RefreshOnFocus;
© 2015 Microsoft