Table of contents

MailMergeDataSource.MappedDataFields 属性 (发布服务器)MailMergeDataSource.MappedDataFields Property (Publisher)

office 365 dev account|上次更新日期: 2018/3/13
2 参与人员

返回一个MailMergeMappedDataFields对象,该对象表示 Microsoft Publisher 中可用的映射的数据字段。Returns a MailMergeMappedDataFields object that represents the mapped data fields available in Microsoft Publisher.


表达式MappedDataFieldsexpression. MappedDataFields

_expression_A 表示MailMergeDataSource对象的变量。_expression_A variable that represents a MailMergeDataSource object.

返回值Return Value



本示例在当前出版物的新页面上创建一个表格,并列出 Publisher 中可用的映射数据字段以及映射到的数据源中的字段。本示例假定当前出版物是邮件合并出版物,数据源字段具有相应的映射数据字段。This example creates a table on a new page of the current publication and lists the mapped data fields available in Publisher and the fields in the data source to which they are mapped. This example assumes that the current publication is a mail merge publication and that the data source fields have corresponding mapped data fields.

Sub MappedFields() 
 Dim intCount As Integer 
 Dim intRows As Integer 
 Dim docPub As Document 
 Dim pagNew As Page 
 Dim shpTable As Shape 
 Dim tblTable As Table 
 Dim rowTable As Row 

 On Error Resume Next 

 Set docPub = ThisDocument 
 Set pagNew = ThisDocument.Pages.Add(Count:=1, After:=1) 
 intRows = docPub.MailMerge.DataSource.MappedDataFields.Count + 1 

 'Creates new table with a heading row 
 Set shpTable = pagNew.Shapes.AddTable(NumRows:=intRows, _ 
 numColumns:=2, Left:=100, Top:=100, Width:=400, Height:=12) 
 Set tblTable = shpTable.Table 
 With tblTable.Rows(1) 
 With .Cells(1).Text 
 .Text = "Mapped Data Field" 
 .Font.Bold = msoTrue 
 End With 
 With .Cells(2).Text 
 .Text = "Data Source Field" 
 .Font.Bold = msoTrue 
 End With 
 End With 

 With docPub.MailMerge.DataSource 
 For intCount = 2 To intRows - 1 
 'Inserts mapped data field name and the 
 'corresponding data source field name 
 tblTable.Rows(intCount - 1).Cells(1).Text _ 
 .Text = .MappedDataFields(Index:=intCount).Name 
 tblTable.Rows(intCount - 1).Cells(2).Text _ 
 .Text = .MappedDataFields(Index:=intCount).DataFieldName 
 End With 
End Sub
© 2018 Microsoft