MailMergeFieldName object (Word)
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.
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
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for