MailMergeDataSource Object

MailMerge
MailMergeDataSource
Multiple objects

Represents the mail merge data source in a mail merge operation.

Using the MailMergeDataSource Object

Use the DataSource property to return the MailMergeDataSource object. The following example displays the name of the data source associated with the active document.

If ActiveDocument.MailMerge.DataSource.Name <> "" Then _
    MsgBox ActiveDocument.MailMerge.DataSource.Name

The following example displays the field names in the data source associated with the active document.

For Each aField In ActiveDocument.MailMerge.DataSource.FieldNames
    MsgBox aField.Name
Next aField

The following example opens the data source associated with Form letter.doc and determines whether the FirstName field includes the name "Kate."

With Documents("Form letter.doc").MailMerge
    .EditDataSource
    If .DataSource.FindRecord(FindText:="Kate", _
            Field:="FirstName") = True Then
        MsgBox "Data was found"
    End If
End With

Properties | ActiveRecord Property | Application Property | ConnectString Property | Creator Property | DataFields Property | FieldNames Property | FirstRecord Property | HeaderSourceName Property | HeaderSourceType Property | Included Property | InvalidAddress Property | InvalidComments Property | LastRecord Property | MappedDataFields Property | Name Property | Parent Property | QueryString Property | RecordCount Property | TableName Property | Type Property

Methods | Close Method | FindRecord Method | SetAllErrorFlags Method | SetAllIncludedFlags Method

Parent Objects | MailMerge Object

Child Objects | MailMergeDataFields Object | MailMergeFieldNames Object | MappedDataFields Object

See Also | MailMergeField Object | MailMergeFields Collection Object