BUG: VBA Requires [out, retval] Parameters to be Pointers

ID: Q244065


The information in this article applies to:
  • Microsoft Visual Basic for Applications (VBA) Software Development Kit (SDK), versions 5.0, 6.0, 6.1


SYMPTOMS

If a method exposed to VBA through either a host application's object model or a control containing an [out, retval] parameter that is not a pointer, VBA might crash when using the Object Browser or IntelliSense. For example, if the type library of an object exposed to VBA contains the following type definition and method definition, VBA may crash:


   typedef
   [
      uuid(4D303331-FBCF-11D2-94E9-006008726F01),
      helpstring("Custom Typedefinition tShort")
   ] short*  tShort;

   HRESULT Football([in, out]BSTR ErrText, [out, retval]tShort ReturnVal); 


CAUSE

This problem occurs because VBA expects parameters marked [out, retval] to be pointers (that is, of type VT_PTR). When this condition is violated, an error occurs.


RESOLUTION

To correct this problem, all parameters in a type library marked [out, retval] should be made pointers. To revisit the previous example, changing the second parameter of the method from tShort to short* alleviates the crash:


   HRESULT Football([in, out]BSTR ErrText, [out, retval]short* ReturnVal); 


STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.

Additional query words:

Keywords : kbSDKVBA kbGrpDSO kbDSupport
Version : winnt:5.0,6.0,6.1
Platform : winnt
Issue type : kbbug


Last Reviewed: October 26, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.