Article ID: 282567 - Last Review: June 17, 2005 - Revision: 2.0 WD2002: VBA Run-Time Error Using MappedDataField NameThis article was previously published under Q282567 SYMPTOMS In Microsoft Word 2002, when you try to return a merge
field by using the MappedDataField name, and your data source is an Outlook
contacts folder, you receive the following error message: Run-time error '5941': The requested member of the collection
does not exist. CAUSE This problem occurs if the MappedDataField name you are
returning contains more than one word, such as the Business Fax, Zip/Postal Code, Home Fax, Email Address and Web Page fields in Outlook. Microsoft Word replaces any spaces in a mail merge field with an underscore characters (_). However, when using Outlook contacts as the data source, the returned names from the MappedDataFields do not contain these underscores. WORKAROUNDMicrosoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers 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 requirements. For more information about how to use the sample
code in this article, click the article number below to view the article in the
Microsoft Knowledge Base: 290140
(http://support.microsoft.com/kb/290140/EN-US/
)
OFFXP: How to Run Sample Code from Knowledge Base Articles
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. STATUSMicrosoft
has confirmed that this is a problem in the Microsoft products that are listed
at the beginning of this article.
MORE INFORMATION In Word, a mapped data field represents a commonly used
name or address information, such as "First Name". If a data source contains a
"First Name" field or a variation (such as "First_Name," "FirstName," "First,"
or "FName"), the field in the data source will automatically map to the
corresponding mapped data field in Word. For more information about the MappedDataField object, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type MappedDataField object in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
| Article Translations
|
Back to the top
