MailMergeDataSource.ActiveRecord プロパティ (Publisher)

取得または設定する まで アクティブな差し込み印刷レコードを表す。 値の取得と設定が可能です。

構文

Activerecord

MailMergeDataSource オブジェクトを表す変数。

戻り値

Long

注釈

有効なレコード番号は、現在のクエリによって作成されたクエリの結果でのレコードの位置を示します。したがって、この番号はデータ ファイルでのレコードの位置を示さない場合があります。

次の使用例は、PostalCode フィールドに入力された値が 10 桁 (米国の郵便番号に 4 桁の細分配達区域コードを加えた番号) かどうかを確認します。 値が 10 桁でない場合、そのレコードは差し込み印刷から除外され、コメントが付けられます。

Sub ValidateZip() 
 
 Dim intCount As Integer 
 
 On Error Resume Next 
 
 With ActiveDocument.MailMerge.DataSource 
 
 'Set the active record equal to the first included 
 'record in the data source 
 .ActiveRecord = 1 
 Do 
 intCount = intCount + 1 
 
 'Set the condition that the PostalCode field 
 'must be greater than or equal to ten digits 
 If Len(.DataFields.Item("PostalCode").Value) < 10 Then 
 
 'Exclude the record if the PostalCode field 
 'is less than ten digits 
 .Included = False 
 
 'Mark the record as containing an invalid address field 
 .InvalidAddress = True 
 
 'Specify the comment attached to the record explaining 
 'why the record was excluded from the mail merge 
 .InvalidComments = "The ZIP Code for this record is " _ 
 & "less than ten digits. It will be removed " _ 
 & "from the mail merge process." 
 
 End If 
 
 'Move the record to the next record in the data source 
 .ActiveRecord = .ActiveRecord + 1 
 
 'End the loop when the counter variable 
 'equals the number of records in the data source 
 Loop Until intCount = .RecordCount 
 End With 
 
End Sub

サポートとフィードバック

Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。