Skip to content

Latest commit

 

History

History
71 lines (43 loc) · 1.74 KB

Word.MailMergeDataSource.FieldNames.md

File metadata and controls

71 lines (43 loc) · 1.74 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
MailMergeDataSource.FieldNames property (Word)
vbawd10.chm152895498
vbawd10.chm152895498
Word.MailMergeDataSource.FieldNames
3e88ee90-c44e-1dbb-dcfd-6ea99cbb1c2c
06/08/2017
medium

MailMergeDataSource.FieldNames property (Word)

Returns a MailMergeFieldNames collection that represents the names of all the fields in the specified mail merge data source. Read-only.

Syntax

expression. FieldNames

expression A variable that represents a 'MailMergeDataSource' object.

Remarks

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

See also

MailMergeDataSource Object

[!includeSupport and feedback]