MailMergeDataField Object
Collapse the table of content
Expand the table of content

MailMergeDataField Object

Office 2007
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 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.

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

© 2015 Microsoft