FieldNames Property 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.

Set MM = ActiveDocument.MailMerge
num = ActiveDocument.MailMerge.DataSource.FieldNames.Count - 1
ReDim mNames(num)
i = 0
For Each aMergeField In MM.DataSource.FieldNames
    mNames(i) = aMergeField.Name
    i = i + 1
Next aMergeField