Class MailMergeFieldName (Word VBA)
The class MailMergeFieldName 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. To use a MailMergeFieldName class variable it first needs to be instantiated, for example
Dim mmf as MailMergeFieldName
Set mmf = ActiveDocument.MailMerge.DataSource.FieldNames(Index:=1)
For Each
Here is an example of processing the MailMergeFieldName items in a collection.
Dim mmfFieldName As MailMergeFieldName
For Each mmfFieldName In ActiveDocument.MailMerge.DataSource.FieldNames
Next mmfFieldName
Index
Returns a Long that represents the position of an item in a collection.
Dim lngIndex As Long
lngIndex = ActiveDocument.MailMerge.DataSource.FieldNames(1).Index
Name
Returns name of the specified object.
Dim strName As String
strName = ActiveDocument.MailMerge.DataSource.FieldNames(1).Name