MailMergeDataSource.DataFields Property

Publisher Developer Reference

Returns a MailMergeDataFields collection that represents the fields in the specified data source.

Syntax

expression.DataFields

expression   A variable that represents a MailMergeDataSource object.

Return Value
MailMergeDataFields

Example

This example displays the value of the value of the FirstName and LastName fields from the active record in the data source attached to the active publication.

Visual Basic for Applications
  Sub ShowNameForActiveRecord()
    Dim mdfFirst As MailMergeDataField
    Dim mdfLast As MailMergeDataField
With ActiveDocument.MailMerge.DataSource
    Set mdfFirst = .<strong>DataFields</strong>.Item("FirstName")
    Set mdfLast = .<strong>DataFields</strong>.Item("LastName")
    MsgBox "The active record in the attached " &amp; _
        vbLf &amp; "data source is : " &amp; _
        mdfFirst.Value &amp; " " &amp; _
        mdfLast.Value
End With

End Sub

See Also