BUG: Interface methods in the VBA Extensibility Library (VBE) are changed (269116)



The information in this article applies to:

  • Microsoft Office 2000 Developer
  • Microsoft Visual Basic for Applications (VBA) Software Development Kit (SDK) 6.0

This article was previously published under Q269116

SYMPTOMS

An out-of-process Automation client that early binds to the Visual Basic for Applications Extensibility 5.0 Library (VBEEXT1.OLB) of Microsoft Office 97 may receive the following error message when an Office 2000 application (or another VBA 6.0 host) is installed on the system:

In Visual Basic:

Run-time error 430:
Class does not support Automation or does not support expected interface.
In Visual C++:

0x80004002 (-2147467262)
E_NOINTERFACE: No such interface supported.
The error message only occurs when the system in question has an Office 2000 application (or VBA6 host application) installed, but the automation server is still an Office 97 (VBA5) application. If the application being automated is upgraded to Office 2000 (VBA6), the client application works normally without changes.

CAUSE

Microsoft Office 2000 ships with version 5.3 of the Visual Basic for Applications Extensibility Library (VBE6EXT.OLB). This library contains the type information for both the VBA5 (Office 97) and VBA6 (Office 2000) extensibility object model, and is designed for backward compatibility. Because the library shares the same library ID (LIBID) as version 5.0, it effectively acts as a replacement for the older type library. Under normal circumstances this would be fine because the library was designed for backwards compatibility.

However, the root (VBE) object did not change between versions and was not updated with a new interface for VBA6. But many of the objects accessed from that object did change and the methods of VBE now point to the new interfaces (with new IIDs) instead of the old ones. Because VBA uses the universal marshaller to remote its interfaces, this mistake can cause Component Object Model (COM) to incorrectly ask the server application for the new (VBA6) interfaces when constructing the proxy/stubs. Because older VBA5 servers do not support these interfaces, they report an error during this construction, and COM reports the error to the client in the preceding manner.

Re-registering the old type library (VBEEXT1.OLB) over the new one (VBE6EXT.OLB) resolves the issue for clients communicating with Office 97 (VBA5) servers, but could result in application errors or faults for new clients that early bind to Office 2000 (VBA6). Microsoft does not recommend this solution.

RESOLUTION

To avoid the problem permanently, Microsoft recommends that clients perform late binding to the VBE object.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

To reproduce the problem you need two computers, one with Microsoft Word 97 and VB6, and another with Word 97 and any other Microsoft Office 2000 application (except Word 2000).

Steps to Reproduce Behavior

  1. On a computer with Word 97 and Microsoft Visual Basic 6.0, start Visual Basic and create a new Standard EXE project. Form1 is created by default.
  2. On the Project menu, click to select References, and then add references to both the Microsoft Word 8.0 Object Library and the Microsoft Visual Basic for Applications Extensibility (5.0 Library).
  3. Add a new Command button to Form1, and then place the following code in the code section:
    Private Sub Command1_Click()
        Dim oWord As Word.Application
        Dim oDoc As Word.Document
        
        Dim oVBE As VBIDE.VBE
        Dim oVBProjs As VBIDE.VBProjects
        
        Set oWord = CreateObject("Word.Application")
        oWord.Visible = True
        Set oDoc = oWord.Documents.Add
        
        Set oVBE = oWord.VBE
        Set oVBProjs = oVBE.VBProjects
        
        MsgBox "Count of projects = " & oVBProjs.Count
        
        Set oVBProjs = Nothing
        Set oVBE = Nothing
        
        oDoc.Saved = True
        oDoc.Close
        Set oDoc = Nothing
        
        oWord.Quit
        Set oWord = Nothing  
    End Sub
    					
  4. Compile the program to an executable and run the program. Note that the code runs and a message box appears with the count of loaded VBA projects that are running. Click OK to close Word.
  5. Transfer the compiled application to another computer with Word 97 installed, and any other Office 2000 application (except Word 2000).
  6. Run the executable, and note that you get a run-time error noting that the object does not support the expected interface.
  7. To fix the problem, change the declaration for VBE to be late bound, as follows:
       Dim oVBE As Object
    					
  8. Recompile and distribute the application. It should run and report the number of loaded projects as expected.

Modification Type:MajorLast Reviewed:11/21/2005
Keywords:kbAutomation kbbug kbnofix kbprogramming KB269116