FieldNames Property
Returns a MailMergeFieldNames collection that represents the names of all the fields in the specified mail merge data source. Read-only.
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.
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.
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
Applies to | MailMergeDataSource Object
See Also | Formula Method | Name Property