This documentation is archived and is not being maintained.

MailMergeDataField.UnMapRecipientField Method

Office 2007
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.

Version Information
 Version Added:  Publisher 2007



expression   A variable that represents a MailMergeDataField object.


This method works only if the parent MailMergeDataField object is mapped to a recipient field. You can use the IsMapped property of the MailMergeDataField object to determine if the object is mapped.


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 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.

See the Item method topic for an example of how you can use the Name property of the DataSource object to determine the index number of the data source you want.

Visual Basic for Applications
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
        Debug.Print "Field unmapped succesfully."
        Debug.Print "This field is not mapped."
    End If

End Sub