OpenDocuments.CreateNewDocument Method
Applies to: SharePoint Foundation 2010
Creates a document based on the specified document template.
expression.CreateNewDocument(bstrTemplateLocation, bstrDefaultSaveLocation)
Parameters
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.
Return Value
true if the document creation succeeds; otherwise false.
Example
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>