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)

expression

An expression that returns an OpenDocuments Control object.

bstrTemplateLocation

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.

bstrDefaultSaveLocation

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;
      }
   }
}
</SCRIPT>
Show:
© 2014 Microsoft