共用方式為


MailMergeDataSource.FindRecord 方法 (Publisher)

在特定的欄位中搜尋文字的指定的合併列印資料來源的內容。 會傳回 Boolean 指出是否已找到搜尋文字; True 是表示 如果找到搜尋文字。

語法

運算式FindRecord (FindTextField)

表達 代表 MailMergeDataSource 物件的 變數。

參數

名稱 必要/選用 資料類型 描述
FindText 必要 String 指定要尋找的文字。
Field 選用 String 要搜尋的欄位名稱。

傳回值

布林值

範例

本範例找到第一筆 FirstName 欄位中包含 Joe 的記錄,並顯示合併出版物的結果。 如果找到記錄,將記錄號碼儲存在變數中。

Sub FindDataSourceRecord() 
 Dim dsMain As MailMergeDataSource 
 Dim intRecord As Integer 
 
 'Makes the data in the data source records instead of the field codes 
 ActiveDocument.MailMerge.ViewMailMergeFieldCodes = False 
 
 Set dsMain = ActiveDocument.MailMerge.DataSource 
 
 If dsMain.FindRecord(FindText:="Joe", _ 
 Field:="FirstName") = True Then 
 intRecord = dsMain.ActiveRecord 
 End If 
 
End Sub

支援和意見反應

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