Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
MapToRecipientField Method
Collapse the table of content
Expand the table of content

MailMergeDataField.MapToRecipientField Method

Office 2007
Maps a field (column) in a particular data source represented by the parent MailMergeDataField object to a recipient field (column) in the master data source (combined mail-merge recipient list).

Version Information
 Version Added:  Publisher 2007

Syntax

expression.MapToRecipientField(bstrValue)

expression   A variable that represents a MailMergeDataField object.

Parameters

NameRequired/OptionalData TypeDescription
bstrValueOptionalStringThe name of the recipient field that the data source column is to be mapped to.

Remarks

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

If you do not pass a value for the optional bstrValue parameter, Microsoft Office Publisher assumes that the field to be mapped has the same name as the recipient field in the master data source to which it is mapped.

If you pass the name of a field that does not exist, Publisher returns an error.

Aa438320.vs_note(en-us,office.12).gif  Note
To add a field, use the AddToRecipientFields method.

Example

The following Microsoft Visual Basic for Applications (VBA) macro shows how to use the MapToRecipientField method to map a data field (column) in a particular data source to 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, replace fieldname with the name of the field in the data source that you want to map to a recipient field, and replace recipientfieldname with the name of the recipient field.

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 Map()

    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 "This field is already mapped"
        
    Else
    
        pubMailMergeDataField.MapToRecipientField ("recipientfieldname")
        Debug.Print "Field mapped successfully."

    End If

End Sub



Community Additions

ADD
Show:
© 2015 Microsoft