Document.MailMergeBeforeMerge Event

Occurs when a merge is executed, before any records merge.

Namespace:  Microsoft.Office.Tools.Word
Assemblies:   Microsoft.Office.Tools.Word.v4.0.Utilities (in Microsoft.Office.Tools.Word.v4.0.Utilities.dll)
  Microsoft.Office.Tools.Word (in Microsoft.Office.Tools.Word.dll)

event EventHandler MailMergeBeforeMerge

To stop the mail merge process, set the Cancel argument of the provided CancelEventArgs to true.

The following code example displays a message before any manual mail merge is run. This example is for an application-level add-in.

private void DocumentMailMergeBeforeMerge()
    Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
    vstoDoc.MailMergeBeforeMerge += new EventHandler(ThisDocument_MailMergeBeforeMerge);

void ThisDocument_MailMergeBeforeMerge(object sender, EventArgs e)
    Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
    System.Windows.Forms.MessageBox.Show("Your mail merge on "
        + vstoDoc.Name + " is now starting.");

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft