MailMergeDataField object (Publisher)

Represents a single merge field in a data source. The MailMergeDataField object is a member of the MailMergeDataFields collection. The MailMergeDataFields collection includes all the data fields in a mail merge or catalog merge data source (for example, Name, Address, and City).


You cannot add fields to the MailMergeDataFields collection. All data fields in a data source are automatically included in the MailMergeDataFields collection.

Use MailMergeDataSource.DataFields (index), where index is the data field name or index number, to return a single MailMergeDataField object. The index number represents the position of the data field in the mail merge data source.


This example retrieves the name of the first field and value of the first record of the FirstName field in the data source attached to the active publication.

Sub GetDataFromSource() 
 With ActiveDocument.MailMerge.DataSource 
 MsgBox "Field Name: " & .DataFields.Item(1).Name & _ 
 "Value: " & .DataFields.Item("FirstName").Value 
 End With 
End Sub



See also

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.