BUG: VBA6 Extensibility Library Breaks Code Written for VBA5 Extensibility Library

ID: Q244224


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

On computers that have both the VBA5 Extensibility library (vbeext1.olb) and the VBA6 Extensibility library (vbe6ext.olb), cross-process automation of the VBA5 Extensibility Object Model fails. In C++ applications, this appears as a failure of a IUnknown::QueryInterface call. In Visual Basic applications, this appears as the following error message:

Run-time error 430 -- "Class does not support Automation or does not support expected interface."
This problem only affects applications writing to the VBA5 Extensibility Model, and not the VBA6 Extensibility Model.


CAUSE

This problem is caused by changes in the type information of the Extensibility Library between VBA5 and VBA6.


RESOLUTION

In order to work around this problem, applications should use late binding to make calls to the VBA5 Extensibility Model. For Visual Basic (VB/VBA) applications, this can be accomplished by changing the declaration for your VBProjects variable from:


Dim objVBProjs as VBIDE.VBProjects 
to

Dim objVBProjs as Object 
For C++ application, this can be accomplished by using the IDispatch interface to search for and Invoke methods.


STATUS

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


MORE INFORMATION

Steps to Reproduce Behavior

To see the problem, add the following code to a Visual Basic project on a computer that has both Office 97 (VBA5) and Office 2000 (VBA6) installed:

(Add references to Excel 97 and VBA 5 Extensibility.)

Sub test()
    Dim objVBE As VBIDE.VBE
    Dim objVBProjs As VBIDE.VBProjects
    Dim objExcelApp As Excel.Application

    Set objExcelApp = New Excel.Application
    
    Set objVBE = objExcelApp.VBE
    ' The following line throws a Run-time error 430.
    ' Class does not support Automation or does not
    ' support expected interface.
    Set objVBProjs = objVBE.VBProjects
End Sub 
To correct the problem, change the code to the following:

(Add references to Excel 97 and VBA 5 Extensibility.)

Sub test()
    Dim objVBE As Object
    Dim objVBProjs As Object
    Dim objExcelApp As Excel.Application

    Set objExcelApp = New Excel.Application
    
    Set objVBE = objExcelApp.VBE
    Set objVBProjs = objVBE.VBProjects
End Sub 

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.