Document.MailMergeAfterRecordMerge Event (2007 System)
Occurs after each record in the data source successfully merges in a mail merge.
Namespace: Microsoft.Office.Tools.Word
Assembly: Microsoft.Office.Tools.Word.v9.0 (in Microsoft.Office.Tools.Word.v9.0.dll)
Syntax
'Declaration
Public Event MailMergeAfterRecordMerge As EventHandler
'Usage
Dim instance As Document
Dim handler As EventHandler
AddHandler instance.MailMergeAfterRecordMerge, handler
public event EventHandler MailMergeAfterRecordMerge
public:
event EventHandler^ MailMergeAfterRecordMerge {
void add (EventHandler^ value);
void remove (EventHandler^ value);
}
JScript does not support events.
Examples
The following code example displays a message when the MailMergeAfterRecordMerge event is raised.
This version is for a document-level customization.
Private Sub DocumentMailMergeAfterRecordMerge()
AddHandler Me.MailMergeAfterRecordMerge, AddressOf ThisDocument_MailMergeAfterRecordMerge
End Sub
Private Sub ThisDocument_MailMergeAfterRecordMerge(ByVal sender As Object, ByVal e As EventArgs)
Dim index As Object = 1
MessageBox.Show(Me.MailMerge.DataSource.DataFields.Item(index).Value & _
" is finished merging.")
End Sub
private void DocumentMailMergeAfterRecordMerge()
{
this.MailMergeAfterRecordMerge += new EventHandler(ThisDocument_MailMergeAfterRecordMerge);
}
void ThisDocument_MailMergeAfterRecordMerge(object sender, EventArgs e)
{
object index = 1;
MessageBox.Show(this.MailMerge.DataSource.DataFields.get_Item(ref index).Value
+ " is finished merging.");
}
This version is for an application-level add-in.
Private Sub DocumentMailMergeAfterRecordMerge()
Dim vstoDoc As Document = Me.Application.ActiveDocument.GetVstoObject()
AddHandler vstoDoc.MailMergeAfterRecordMerge, AddressOf ThisDocument_MailMergeAfterRecordMerge
End Sub
Private Sub ThisDocument_MailMergeAfterRecordMerge(ByVal sender As Object, ByVal e As EventArgs)
Dim vstoDoc As Document = Me.Application.ActiveDocument.GetVstoObject()
Dim index As Object = 1
System.Windows.Forms.MessageBox.Show(vstoDoc.MailMerge.DataSource.DataFields.Item(index).Value & _
" is finished merging.")
End Sub
private void DocumentMailMergeAfterRecordMerge()
{
Document vstoDoc = this.Application.ActiveDocument.GetVstoObject();
vstoDoc.MailMergeAfterRecordMerge += new EventHandler(ThisDocument_MailMergeAfterRecordMerge);
}
void ThisDocument_MailMergeAfterRecordMerge(object sender, EventArgs e)
{
object index = 1;
Document vstoDoc = this.Application.ActiveDocument.GetVstoObject();
System.Windows.Forms.MessageBox.Show(vstoDoc.MailMerge.DataSource.DataFields.get_Item(ref index).Value
+ " is finished merging.");
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
See Also
Reference
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. |