OnMergeRequest Event
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

_XDocumentEventSink2_Event.OnMergeRequest Event (Microsoft.Office.Interop.InfoPath.SemiTrust)

Occurs when the merge operation is invoked either from the Microsoft Office InfoPath 2007 user interface or from the command line by using the /aggregate option.

Namespace: Microsoft.Office.Interop.InfoPath.SemiTrust
Assembly: Microsoft.Office.Interop.InfoPath.SemiTrust (in microsoft.office.interop.infopath.semitrust.dll)

event _XDocumentEventSink2_OnMergeRequestEventHandler OnMergeRequest

If the ReturnStatus property of the MergeEventObject object is set to false, InfoPath cancels the merge operation. If an error occurs in the code for the OnMergeRequest event, InfoPath ignores the error and relies on the ReturnStatus property If the ReturnStatus property is not explicitly set, the default value of false is used.

For InfoPath forms stored in a Windows SharePoint Services form library, the OnMergeRequest event also occurs when the MergeDocuments2 method of the OpenXMLDocuments control is executed. For more information on the OpenXMLDocuments control, see the SharePoint Products and Technologies 2003 Software Development Kit (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/spptsdk/html/SPSDKWelcome.asp), which is available on the Microsoft SharePoint Products and Technologies Web site (http://msdn.microsoft.com/sharepoint).


There is no user interface (UI) in the InfoPath form design window for creating this event handler. To add this event handler to the project, include the InfoPathEventHandler attribute as it appears in the example.

In the following example, the OnMergeRequest event handler performs a merge operation, and it sets variables to indicate the status of the merge operation:

private bool _merging = false;

public void OnMergeRequest(MergeEvent e)
 // Set global property to indicate that forms are being merged.
 if (e.Index == 0)
  _merging = true;

 e.ReturnStatus = true;
 if ((e.Index + 1) == e.Count)
  _merging = false;
  thisXDocument.UI.Alert("Your request to merge " + e.Count + " files is now complete.");
© 2016 Microsoft