Dela via


Document.MailMergeAfterMerge Event (2007 System)

Occurs after all records in a mail merge have merged successfully.

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

Syntax

'Declaration
Public Event MailMergeAfterMerge As MailMergeAfterMergeEventHandler
'Usage
Dim instance As Document 
Dim handler As MailMergeAfterMergeEventHandler 

AddHandler instance.MailMergeAfterMerge, handler
public event MailMergeAfterMergeEventHandler MailMergeAfterMerge
public:
 event MailMergeAfterMergeEventHandler^ MailMergeAfterMerge {
    void add (MailMergeAfterMergeEventHandler^ value);
    void remove (MailMergeAfterMergeEventHandler^ value);
}
JScript does not support events.

Examples

The following code example displays a message when the MailMergeAfterMerge event is raised.

This version 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.");
}

This version is for an application-level add-in.

Private Sub DocumentMailMergeAfterMerge()
    Dim vstoDoc As Document = Me.Application.ActiveDocument.GetVstoObject()
    AddHandler vstoDoc.MailMergeAfterMerge, AddressOf ThisDocument_MailMergeAfterMerge
End Sub 

Private Sub ThisDocument_MailMergeAfterMerge(ByVal sender As Object, ByVal e As  _
    Microsoft.Office.Tools.Word.MailMergeAfterMergeEventArgs)
    Dim vstoDoc As Document = Me.Application.ActiveDocument.GetVstoObject()
    System.Windows.Forms.MessageBox.Show("Your mail merge on " & vstoDoc.Name & " is now finished.")
End Sub
private void DocumentMailMergeAfterMerge()
{
    Document vstoDoc = this.Application.ActiveDocument.GetVstoObject();
    vstoDoc.MailMergeAfterMerge += new Microsoft.Office.Tools.Word.MailMergeAfterMergeEventHandler(ThisDocument_MailMergeAfterMerge);
}

void ThisDocument_MailMergeAfterMerge(object sender, Microsoft.Office.Tools.Word.MailMergeAfterMergeEventArgs e)
{
    Document vstoDoc = this.Application.ActiveDocument.GetVstoObject();
    System.Windows.Forms.MessageBox.Show("Your mail merge on " 
        + vstoDoc.Name + " is now finished.");
}

.NET Framework Security

See Also

Reference

Document Class

Document Members

Microsoft.Office.Tools.Word Namespace

Change History

Date

History

Reason

July 2008

Added a version of the code example for an application-level add-in.

SP1 feature change.