MailMergeDataSource object (Word)

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

Remarks

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

Methods

Name
Close
FindRecord
SetAllErrorFlags
SetAllIncludedFlags

Properties

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

See also

Word Object Model Reference

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.