返回一个 MappedDataFields 对象,该对象代表在 Microsoft Word 中有效的映射数据域。
expression.MappedDataFields
expression 必需。该表达式返回一个 MailMergeDataSource 对象。
本示例创建一个可在 Word 中使用的映射数据域和被映射的数据源域的制表符列表。本示例假定当前文档是一个邮件合并文档。
Sub MappedFields()
Dim intCount As Integer
Dim docCurrent As Document
Dim docNew As Document
On Error Resume Next
Set docCurrent = ThisDocument
Set docNew = Documents.Add
'Add leader tab to new document
docNew.Paragraphs.TabStops.Add _
Position:=InchesToPoints(3.5), _
Leader:=wdTabLeaderDots
With docCurrent.MailMerge.DataSource
'Insert heading paragraph for tabbed columns
docNew.Content.InsertAfter "Word Mapped Data Field" _
& vbTab & "Data Source Field"
Do
intCount = intCount + 1
'Insert Word mapped data field name and the
'corresponding data source field name
docNew.Content.InsertAfter .MappedDataFields( _
Index:=intCount).Name & vbTab & _
.MappedDataFields(Index:=intCount) _
.DataFieldName
'Insert paragraph
docNew.Content.InsertParagraphAfter
Loop Until intCount = .MappedDataFields.Count
End With
End Sub