Compartilhar via


DocumentBase.MailMergeBeforeRecordMerge Event

Definition

Occurs as a merge is executed for the individual records in a merge.

public:
 event System::ComponentModel::CancelEventHandler ^ MailMergeBeforeRecordMerge;
public event System.ComponentModel.CancelEventHandler MailMergeBeforeRecordMerge;
member this.MailMergeBeforeRecordMerge : System.ComponentModel.CancelEventHandler 
Public Custom Event MailMergeBeforeRecordMerge As CancelEventHandler 

Event Type

Examples

The following code example displays a message before the first record is merged. To use this example, run it from the ThisDocument class in a document-level project.

private void DocumentMailMergeBeforeRecordMerge()
{
    this.MailMergeBeforeRecordMerge += new System.ComponentModel.CancelEventHandler(ThisDocument_MailMergeBeforeRecordMerge);
}

void ThisDocument_MailMergeBeforeRecordMerge(object sender, System.ComponentModel.CancelEventArgs e)
{
    string message = this.MailMerge.DataSource.DataFields[1].Value + " is now merging.";
    MessageBox.Show(message);
}
Private Sub DocumentMailMergeBeforeRecordMerge()
    AddHandler Me.MailMergeBeforeRecordMerge, AddressOf ThisDocument_MailMergeBeforeRecordMerge
End Sub

Private Sub ThisDocument_MailMergeBeforeRecordMerge(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs)
    Dim index As Object = 1
    MessageBox.Show(Me.MailMerge.DataSource.DataFields.Item(index).Value & _
      " is now merging.")
End Sub

Remarks

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

Applies to