Document.MailMergeDataSourceLoad Event

Definition

Occurs when the data source is loaded for a mail merge.

public:
 event EventHandler ^ MailMergeDataSourceLoad;
event EventHandler MailMergeDataSourceLoad;
member this.MailMergeDataSourceLoad : EventHandler 
Event MailMergeDataSourceLoad As EventHandler 

Event Type

Examples

The following example displays a message when the data source for a mail merge is loaded. This example is for an application-level add-in.

private void DocumentMailMergeDataSourceLoad()
{
    Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
    vstoDoc.MailMergeDataSourceLoad += new EventHandler(ThisDocument_MailMergeDataSourceLoad);
}

void ThisDocument_MailMergeDataSourceLoad(object sender, EventArgs e)
{
    object index = 1;
    Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
    System.Windows.Forms.MessageBox.Show(vstoDoc.MailMerge.DataSource.DataFields.get_Item(ref index).Value
         + " is loading.");
}
Private Sub DocumentMailMergeDataSourceLoad()
    Dim vstoDoc As Document = Globals.Factory.GetVstoObject(Me.Application.ActiveDocument)
    AddHandler vstoDoc.MailMergeDataSourceLoad, AddressOf ThisDocument_MailMergeDataSourceLoad
End Sub

Private Sub ThisDocument_MailMergeDataSourceLoad(ByVal sender As Object, ByVal e As EventArgs)
    Dim vstoDoc As Document = Globals.Factory.GetVstoObject(Me.Application.ActiveDocument)
    Dim index As Object = 1
    System.Windows.Forms.MessageBox.Show(vstoDoc.MailMerge.DataSource.DataFields.Item(index).Value & _
        " is loading.")
End Sub

Applies to