Publisher) (MailMergeDataFields 物件

MailMergeDataField 一群 代表合併列印或型錄合併列印資料來源中的資料欄位的物件。

註解

您無法將欄位新增至 MailMergeDataFields 集合。 當資料欄位新增到資料來源時、 欄位自動隨附於 MailMergeDataFields 集合。

使用 MailMergeDataSource.DataFields 屬性可傳回 MailMergeDataFields 集合。

使用 DataFields (索引) ,其中 index 是資料欄名或索引編號,可傳回單一 MailMergeDataField 物件。 該索引編號代表資料欄位在合併列印資料來源中的位置。

範例

下列範例會顯示附加至使用中出版物的資料來源中的欄位名稱。

Sub ShowFieldNames() 
 Dim intCount As Integer 
 With ActiveDocument.MailMerge.DataSource.DataFields 
 For intCount = 1 To .Count 
 MsgBox .Item(intCount).Name 
 Next 
 End With 
End Sub

This example retrieves the name of the first field and value of the first record of the FirstName field in the data source attached to the active publication.

Sub GetDataFromSource() 
 With ActiveDocument.MailMerge.DataSource.DataFields 
 MsgBox "First field name: " & .Item(1).Name & vbLf & _ 
 "Value of the first record of the FirstName field: " & _ 
 .Item("FirstName").Value 
 End With 
End Sub

方法

屬性

另請參閱

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應