Table of contents
TOC
Collapse the table of content
Expand the table of content

MailMergeDataFields Object (Publisher)

office 365 dev account|Last Updated: 8/24/2017
|
3 Contributors

A collection of MailMergeDataField objects that represent the data fields in a mail merge or catalog merge data source.

Remarks

You cannot add fields to the MailMergeDataFields collection. When a data field is added to a data source, the field is automatically included in the MailMergeDataFields collection.

Example

Use the DataFields property to return the MailMergeDataFields collection.

The following example displays the field names in the data source attached to the active publication.

Sub ShowFieldNames() 
 Dim intCount As Integer 
 With ActiveDocument.MailMerge.DataSource.DataFields 
 For intCount = 1 To .Count 
 MsgBox .Item(intCount).Name 
 Next 
 End With 
End Sub

Use DataFields (index), where index is the data field name or the 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.DataFields 
 MsgBox "First field name: " & .Item(1).Name & vbLf & _ 
 "Value of the first record of the FirstName field: " & _ 
 .Item("FirstName").Value 
 End With 
End Sub

Methods

Name
Item

Properties

Name
Application
Count
Creator
Parent
© 2018 Microsoft