Table of contents
Collapse the table of content
Expand the table of content

MailMergeDataSource.EditRecord Method (Publisher)

office 365 dev account|Last Updated: 8/24/2017
3 Contributors

Changes one of the data fields in one of the records in the master data source (the combined mail-merge recipient list).


expression. EditRecord( lRec, varField, Value)

_expression_A variable that represents a MailMergeDataSource object.


NameRequired/OptionalData TypeDescription
lRecRequiredLongThe ID of the record you want to edit.
varFieldRequiredVariantThe data field (column) that contains the value you want to change.
ValueRequiredVariantThe value to be changed.


You can use the EditRecord method to correct data source information that is in error, such as an outdated recipient address.

The EditRecord method does not make any changes to the individual data sources that together make up the master data source.


The following Microsoft Visual Basic for Applications (VBA) macro shows how to use the EditRecord method to change the value of a single column in a particular record in the master data source (the combined mail-merge recipient list).

Before running this macro, replace recordID with the index number of the record in the data source that you want to edit; replace fieldname with the name of the field (column) in the record that you want to edit; and replace value with the new value you want to set for the field.

Public Sub EditRecord_Example() 

 Dim pubMailMergeDataSource As Publisher.MailMergeDataSource 

 Set pubMailMergeDataSource = ThisDocument.MailMerge.DataSource 

 pubMailMergeDataSource.EditRecord recordID, "fieldname", "value" 

End Sub
© 2018 Microsoft