Compartir a través de


Propiedad MailMergeDataSource.RecordCount (Publisher)

Devuelve un Long que representa el número de registros del origen de datos. Solo lectura.

Sintaxis

expresión. RecordCount

expresión Variable que representa un objeto MailMergeDataSource .

Valor devuelto

Long

Ejemplo

En este ejemplo se validan los códigos postales de cinco dígitos en el origen de datos adjunto. Si la longitud del código postal es inferior a cinco dígitos, se excluirá el registro del proceso de combinación de correspondencia.

En este ejemplo se supone que los códigos postales son códigos U.S. ZIP. Puede modificar este ejemplo para buscar códigos POSTALes que tengan un código de localizador de 4 dígitos anexado al código postal y, a continuación, excluir todos los registros que no contengan el código del localizador.

Sub Validate 
 
 Dim intCount As Integer 
 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 field six must be greater than or 
 'equal to five digits in length 
 If Len(.DataFields.Item(6).Value) < 5 Then 
 
 'Exclude the record if field six contains fewer than five 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 has " _ 
 & "fewer than five 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 

Soporte técnico y comentarios

¿Tiene preguntas o comentarios sobre VBA para Office o esta documentación? Vea Soporte técnico y comentarios sobre VBA para Office para obtener ayuda sobre las formas en las que puede recibir soporte técnico y enviar comentarios.