OpenXMLDocuments.CreateNewDocument2 Method

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Creates an XML document or form based on the specified template and instance of Internet Explorer.

expression.CreateNewDocument2(pdisp, bstrTemplateLocation, bstrDefaultSaveLocation)



An expression that returns an OpenXMLDocuments Control object.


An Object representing a pointer to the Internet Explorer instance that is calling the CreateNewDocument2 method. Using a null value for this argument results in the method being executed on the primary Internet Explorer thread. As an alternative, you can use the CreateNewDocument method if you do not need to pass an object with this argument.


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


A string that contains the URL that specifies a default location for saving the new XML document or form. UNC paths cannot be used.

Return Value

true if the XML document or form creation succeeds; otherwise false.


The following example creates a new XML document or form whose template location and default location for saving are specified by the values for the strTempLoc and strSaveLoc variables that are passed to the CreateNewDocument2 method. The example assumes the existence of a form named frmCreateDoc that has two input boxes, TempLocation and SaveLocation.

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

function createNewXMLDocument()
   // Create an instance of the OpenXMLDocuments object.
   xmlDocObject = new ActiveXObject("SharePoint.OpenXMLDocuments.1");

   // If the OpenXMLDocuments object was successfully created,
   // get the template location and save location values from the
   // form's input boxes.
   if (xmlDocObject)
   var strTempLoc = document.frmCreateDoc.TempLocation.value;
   var strSaveLoc = document.frmCreateDoc.SaveLocation.value;

      // Create the new XML document or form, and then refresh the window.
      if (xmlDocObject.CreateNewDocument2(window, strTempLoc, strSaveLoc))
         window.onfocus = RefreshOnFocus;

See Also


OpenXMLDocuments Control

OpenXMLDocuments Members