Share via


MailMergeFieldName Object

Word Developer Reference

Represents a mail merge field name in a data source. The MailMergeFieldName object is a member of the MailMergeFieldNames collection. The MailMergeFieldNames collection includes all the data field names in a mail merge data source.

Remarks

Use FieldNames(Index), where Index is the index number, to return a single MailMergeFieldName object. The index number represents the position of the field in the mail merge data source. The following example retrieves the name of the last field in the data source attached to the active document.

Visual Basic for Applications
  alast = ActiveDocument.MailMerge.DataSource.FieldNames.Count
afirst = ActiveDocument.MailMerge.DataSource.FieldNames(alast).Name
MsgBox afirst

You cannot add fields to the MailMergeFieldNames collection. Field names in a data source are automatically included in the MailMergeFieldNames collection.

See Also