OpenXMLDocuments.MergeDocuments2 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.

Opens the specified XML document or form for merging, or for handling multiple XML documents or forms, within its associated application, based on the specified instance of Internet Explorer.

expression.MergeDocuments2(pdisp, bstrTemplateLocation, varDocuments, bstrDefaultSaveLocation)



An expression that returns an OpenXMLDocuments Control object.


An Object representing a pointer to the Internet Explorer instance that is calling the MergeDocuments2 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 MergeDocuments method if you do not need to pass an object with this argument.


A string that contains the URL of the location of the XML document or form to open for merging.


An Object representing a collection of XML documents or forms, expressed as variants, to be merged. Implementation includes the ability to pass a single variant, a collection of variants, or null. The Windows SharePoint Services form library's combine.aspx page passes NULL, a single XML document or form URL, or a collection of XML document or form URLs..


A string that contains the URL that specifies the default location for saving for the resulting XML document or form that has been merged.

Return Value

true if the XML document or form template successfully opens; otherwise false.


The following example opens one or more XML documents or forms for merging, whose template and location for saving are specified by the values for the strTempLoc and strSaveLoc variables that are passed to the MergeDocuments2 method. The varDocuments argument of the MergeDocuments2 method accepts an object containing a collection of XML documents or forms that will be used during the merge. The example assumes the existence of a form named frmMergeDoc that has two input boxes, TempLocation and SaveLocation.

<script language="JavaScript">
function mergeDocuments()
   // Create an instance of the OpenXMLDocuments object.
   xmlDocObject = new ActiveXObject("SharePoint.OpenXMLDocuments");

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

      // Build the collection of documents to merge.  MergeDocuments is
      // optimized to work with a collection of HTML checkbox controls like
      // document.all.chk for the following HTML:
      //    <checkbox id="chk" HREF="type a location here">
      //    <checkbox id="chk" HREF="type a location here">
      // The same result chan be acheived from script by wrapping and
      // array of values and an iterator like this:
      var docCol = Array(
      {checked:true, HREF:"type a location here"},
      {checked:true, HREF:"type a location here"});

      // Declare an iterator function for the collection of documents.
      function item(index)
         return docCol[index];

      // Wrap the collection and the interator into an object suitable
      // for MergeDocuments2 call.
      var docWrap = {length:docCol.length, item:item};
      // Open the XML document or form template for customization.
      xmlDocObject.MergeDocuments2(window, strTempLoc, docWrap, strSaveLoc);

See Also


OpenXMLDocuments Control

OpenXMLDocuments Members