DocumentBase.MailMergeBeforeMerge Event

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

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

Syntax

'Declaration
Public Event MailMergeBeforeMerge As EventHandler
public event EventHandler MailMergeBeforeMerge

Remarks

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

Examples

The following code example displays a message before any manual mail merge is run. To use this example, run it from the ThisDocument class in a document-level project.

Private Sub DocumentMailMergeBeforeMerge()
    AddHandler Me.MailMergeBeforeMerge, AddressOf ThisDocument_MailMergeBeforeMerge
End Sub 

Private Sub ThisDocument_MailMergeBeforeMerge(ByVal sender As Object, ByVal e As EventArgs)
    MessageBox.Show("Your mail merge on " & Me.Name & " is now starting.")
End Sub
private void DocumentMailMergeBeforeMerge()
{
    this.MailMergeBeforeMerge += new EventHandler(ThisDocument_MailMergeBeforeMerge);
}

void ThisDocument_MailMergeBeforeMerge(object sender, EventArgs e)
{
    MessageBox.Show("Your mail merge on "
        + this.Name + " is now starting.");
}

.NET Framework Security

See Also

Reference

DocumentBase Class

Microsoft.Office.Tools.Word Namespace