MailMergeDataField.UnMapRecipientField method (Publisher)

Undoes the mapping between the parent MailMergeDataField object in a particular data source and the recipient field in the master data source (combined mail-merge recipient list) to which it is currently mapped.

Syntax

expression.UnMapRecipientField

expression A variable that represents a MailMergeDataField object.

Remarks

This method works only if the parent MailMergeDataField object is mapped to a recipient field. Use the IsMapped property to determine if the object is mapped.

Example

The following Microsoft Visual Basic for Applications (VBA) macro shows how to use the UnmapRecipientField method to undo the mapping between a data field (column) in a particular data source and a field in the master data source (combined recipient list) for the publication.

Before running this macro, replace datasourceindex with the index number of a valid data source in the data source collection of the active document, and replace fieldname with the name of the field in the data source that you want to remove from the combined list of recipient fields.

Note

For an example of how you can use the Name property of the DataSource object to determine the index number of the data source that you want, see the MailMergeDataSources.Item method.

Public Sub UnmapRecipientField_Example() 
 
 Dim pubMailMergeDataSources As Publisher.MailMergeDataSources 
 Dim pubMailMergeDataField As Publisher.MailMergeDataField 
 
 Set pubMailMergeDataSources = ThisDocument.MailMerge.DataSource.DataSources 
 Set pubMailMergeDataField = pubMailMergeDataSources.Item(datasourceindex).DataFields.Item("fieldname") 
 
 If pubMailMergeDataField.IsMapped Then 
 
 pubMailMergeDataField.UnMapRecipientField 
 Debug.Print "Field unmapped successfully." 
 
 Else 
 
 Debug.Print "This field is not mapped." 
 
 End If 
 
End Sub

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.