Propriedade MailMergeDataSource.ActiveRecord (Publisher)
Retorna ou define um valor Long que representa o registro de mala direta ativo. Leitura/gravação.
Sintaxe
expressão. Activerecord
Expressão Uma variável que representa um objeto MailMergeDataSource .
Valor de retorno
Long
Comentários
O número do registro ativo é a posição do registro no resultado da consulta, produzido pelas opções da consulta atual; desta forma, este número não é necessariamente a posição do registro na fonte de dados.
Exemplo
Este exemplo valida o valor inserido no campo PostalCode, verificando se tem dez caracteres de tamanho (CEP americano mais código localizador de 4 dígitos). Se não for validado, será excluído da mala direta e marcado com um comentário.
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
Suporte e comentários
Tem dúvidas ou quer enviar comentários sobre o VBA para Office ou sobre esta documentação? Confira Suporte e comentários sobre o VBA para Office a fim de obter orientação sobre as maneiras pelas quais você pode receber suporte e fornecer comentários.