Export (0) Print
Expand All
0 out of 1 rated this helpful - Rate this topic

OpenXMLDocuments.CreateNewDocument2 Method

Published: May 2010

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


expression.CreateNewDocument2(pdisp, bstrTemplateLocation, bstrDefaultSaveLocation)

expression

An expression that returns an OpenXMLDocuments Control object.

pdisp

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.

bstrTemplateLocation

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.

bstrDefaultSaveLocation

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

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;
      }
   }
}
</script>
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.