MailMergeAfterMergeEventHandler Delegate
Represents the method that handles the MailMergeAfterMerge event of a Document.
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)
Syntax
'Declaration
Public Delegate Sub MailMergeAfterMergeEventHandler ( _
sender As Object, _
e As MailMergeAfterMergeEventArgs _
)
public delegate void MailMergeAfterMergeEventHandler(
Object sender,
MailMergeAfterMergeEventArgs e
)
Parameters
sender
Type: System.ObjectThe source of the event.
e
Type: Microsoft.Office.Tools.Word.MailMergeAfterMergeEventArgsA MailMergeAfterMergeEventArgs that contains the event data.
Remarks
When you create a MailMergeAfterMergeEventHandler delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, until you remove the delegate..
Examples
The following code example demonstrates an event handler for the MailMergeAfterMerge event. The event handler displays a message after all records in a mail merge have merged successfully.
This example is for a document-level customization.
Private Sub DocumentMailMergeAfterMerge()
AddHandler Me.MailMergeAfterMerge, AddressOf ThisDocument_MailMergeAfterMerge
End Sub
Private Sub ThisDocument_MailMergeAfterMerge(ByVal sender As Object, ByVal e As _
Microsoft.Office.Tools.Word.MailMergeAfterMergeEventArgs)
MessageBox.Show("Your mail merge on " & Me.Name & " is now finished.")
End Sub
private void DocumentMailMergeAfterMerge()
{
this.MailMergeAfterMerge += new Microsoft.Office.Tools.Word.MailMergeAfterMergeEventHandler(ThisDocument_MailMergeAfterMerge);
}
void ThisDocument_MailMergeAfterMerge(object sender, Microsoft.Office.Tools.Word.MailMergeAfterMergeEventArgs e)
{
MessageBox.Show("Your mail merge on "
+ this.Name + " is now finished.");
}