Share via


MailMergeDataField Object [Publisher 2003 VBA Language Reference]

MailMergeDataFields
MailMergeDataField

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).

Using the MailMergeDataField Object

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.

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

Remarks

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

Properties | Application Property | Creator Property | FieldType Property | Index Property | Name Property | Parent Property | Value Property

Methods | Insert Method

Parent Objects

Child Objects