SYMPTOMS
When you run a Microsoft Visual Basic for Applications macro
to return a merge field from your Microsoft Outlook Contacts folder and you use
the MappedDataField name, you may receive the following error message:
Run-time error '5941': The requested member of the collection does
not exist.
WORKAROUND
Microsoft provides programming examples for illustration only, without warranty
either expressed or implied, including, but not limited to, the implied
warranties of merchantability and/or fitness for a particular purpose. This
article assumes that you are familiar with the programming language being
demonstrated and the tools used to create and debug procedures. Microsoft
support professionals can help explain the functionality of a particular
procedure, but they will not modify these examples to provide added
functionality or construct procedures to meet your specific needs. If you have
limited programming experience, you may want to contact a Microsoft Certified
Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more
information about Microsoft Certified Partners, see the following Microsoft Web
site:
For additional information about the support options available
from Microsoft, visit the following Microsoft Web site:
When you want to return the merge field for a
MappedDataField object, use the DataFieldIndex property instead of the
DataFieldName property.
Note The following sample macro uses the DataFieldIndex of a
MappedDataField constant (wdBusinessFax) to determine the fax number for the
first record in the data source.
Sub MappedField()
Dim objDsource As MailMergeDataSource
Dim BFAXindex As Integer
Dim objBFX As MailMergeDataField
'Return the mail merge data source.
Set objDsource = ActiveDocument.MailMerge.DataSource
With objDsource
'Set the first record as the active record.
.ActiveRecord = wdFirstDataSourceRecord
'Return the index for the wdBusinessFax MappedDataField.
BFAXindex = .MappedDataFields(wdBusinessFax).DataFieldIndex
'Return the corresponding mail merge field.
Set objBFX = .DataFields(BFAXindex)
'Return the business fax number.
MsgBox objBFX.Value
End With
End Sub