Share via


MailMergeDataSource.FieldNames Property

Word Developer Reference

Returns a MailMergeFieldNames collection that represents the names of all the fields in the specified mail merge data source. Read-only.

Syntax

expression.FieldNames

expression   A variable that represents a MailMergeDataSource object.

Remarks

For information about returning a single member of a collection, see Returning an Object from a Collection.

Example

This example displays the name of the first field in the data source attached to the active mail merge main document.

Visual Basic for Applications
  MsgBox ActiveDocument.MailMerge.DataSource.FieldNames(1).Name

This example uses the mNames() array to store the names of each merge field contained in the data source attached to the active document.

Visual Basic for Applications
  Dim mNames As Variant
Dim mmTemp As MailMerge
Dim intCount As Integer
Dim intIncrement As Integer
Dim mmfnLoop As MailMergeFieldName

Set mmTemp = ActiveDocument.MailMerge intCount = _ ActiveDocument.MailMerge.DataSource.FieldNames.Count - 1

ReDim mNames(intCount) intIncrement = 0

For Each mmfnLoop In mmTemp.DataSource.FieldNames mNames(intIncrement) = mmfnLoop.Name intIncrement = intIncrement + 1 Next mmfnLoop

See Also