Word VBA教程:MappedDataFields属性

返回一个 MappedDataFields对象,该对象代表在 Microsoft Word 中有效的映射数据域。

expression.MappedDataFields

expression   必需。该表达式返回一个MailMergeDataSource对象。

VBA示例

本示例创建一个可在 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

Word VBA教程

Word VBA参考教程:目录1 Word VBA参考教程:目录2
Word VBA参考教程:目录3 Word VBA参考教程:目录4
Word VBA参考教程:目录5 Word VBA参考教程:目录6
Word VBA参考教程:目录7 Word VBA参考教程:目录8
Word VBA参考教程:目录9 Word VBA参考教程:目录10
版权所有 © 中山市飞娥软件工作室 证书:粤ICP备09170368号