Compartir a través de


Propiedad MailMergeDataSource.ActiveRecord (Publisher)

Devuelve o establece un Long que representa el registro de combinación de correspondencia activo. Lectura y escritura.

Sintaxis

expresión. ActiveRecord

expresión Variable que representa un objeto MailMergeDataSource .

Valor devuelto

Long

Observaciones

El número de registro activo es la posición del registro en el resultado de la consulta producido por las opciones de consulta actuales; como tal, este número no representa necesariamente la posición del registro en el origen de datos.

Ejemplo

En este ejemplo se confirma que el valor escrito en el campo PostalCode tiene diez caracteres (código postal de EE.UU. más un código de localización de cuatro). De no ser así, se excluirá de la combinación de correspondencia y se marcará con un comentario.

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

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.