PRB: Type Mismatch When Passing Variants to Word Using OLELast reviewed: September 29, 1997Article ID: Q137096 |
The information in this article applies to:
SYMPTOMSWhen trying to pass a Variant data type to Microsoft Word using OLE automation, a "Type mismatch" error occurs. For example, if objVar is an object variable set to a Word.Basic object, and Text1 is some text box containing a string value, the following line of code generates the error:
objVar.Insert Text1This problem did not exist in Visual Basic version 3.0, so it must be taken into consideration when doing any code porting and/or upgrading.
RESOLUTIONTo avoid this problem, the variable passed to Word must be explicitly typed. The previous example can be replaced by either of the following to prevent this error:
objVar.Insert Text1.Text -or- objVar.Insert CStr(Text1) STATUSThis behavior is by design
MORE INFORMATIONSteps to Reproduce and Correct Behavior
Keywords : IAPOLE VB4ALL VB4WIN vbwin GnrlVb kbprg Technology : kbole kbvba Version : WINDOWS:4.0 Platform : WINDOWS Issue type : kbprb |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |