MappedDataField object (Word)
A mapped data field is a field contained within Microsoft Word that represents commonly used name or address information, such as "First Name." If a data source contains a "First Name" field or a variation (such as "First_Name," "FirstName," "First," or "FName"), the field in the data source will automatically map to the corresponding mapped data field in Word. If a document or template is to be merged with more than one data source, mapped data fields make it unnecessary to reenter the fields into the document to agree with the field names in the database.
Remarks
Use the MappedDataFields property to return a MappedDataField object. This example returns the data source field name for the wdFirstName mapped data field. This example assumes the current document is a mail merge document. A blank string value returned for the DataFieldName property indicates that the mapped data field is not mapped to a field in the data source.
Sub MappedFieldName()
With ActiveDocument.MailMerge.DataSource
If .MappedDataFields.Item(wdFirstName).DataFieldName <> "" Then
MsgBox "The mapped data field 'FirstName' is mapped to " _
& .MappedDataFields(Index:=wdFirstName) _
.DataFieldName & "."
Else
MsgBox "The mapped data field 'FirstName' is not " & _
"mapped to any of the data fields in your " & _
"data source."
End If
End With
End Sub
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