Microsoft KB Archive/170356

= BUG: Cannot Reference Excel 8.0 Object Library from VB 4.0x =

Article ID: 170356

Article Last Modified on 2/12/2007

-

APPLIES TO

 Microsoft Visual Basic 4.0 Standard Edition, when used with:  Microsoft Windows NT 4.0

 Microsoft Windows 95  Microsoft Visual Basic 4.0 Professional Edition, when used with:  Microsoft Windows NT 4.0

 Microsoft Windows 95</li></ul> </li> Microsoft Visual Basic 4.0 Enterprise Edition, when used with:  Microsoft Windows NT 4.0</li></ul>

 Microsoft Windows 95</li></ul> </li> Microsoft Excel 5.0 Standard Edition</li> Microsoft Excel 5.0a</li> Microsoft Excel 5.0c</li> Microsoft Excel 5.0 Standard Edition</li> Microsoft Excel 95 Standard Edition</li> Microsoft Excel 95a</li> Microsoft Excel 97 Standard Edition</li> Microsoft Office 4.2 Standard Edition</li> Microsoft Office 4.2b</li> <li>Microsoft Office 4.2c</li> <li>Microsoft Office 4.3 Standard Edition</li> <li>Microsoft Office 4.3c</li> <li>Microsoft Office 95 Standard Edition</li> <li>Microsoft Office 95a</li> <li>Microsoft Office 95b</li> <li>Microsoft Office 97 Standard Edition</li> <li>Microsoft Project 98 Standard Edition</li> <li>Microsoft Project 4.1 Standard Edition</li> <li>Microsoft Project 4.1a</li> <li>Microsoft Project 4.0 Standard Edition</li></ul>

-

<div class="notice_section">

This article was previously published under Q170356

<div class="symptoms_section">

SYMPTOMS
Microsoft Visual Basic 4.0x does not allow addition of the Microsoft Excel 8.0 Object Library via Tools/References when the Microsoft Excel 5.0 Object Library is listed there.

<div class="cause_section">

CAUSE
When adding a new version of an object (or type) library to its Tools/Reference list, Microsoft Visual Basic 4.0x, in spite of the distinctly different version numbers of the old and new object libraries, insists, via an internal string-comparison routine, that the new library's Locale/Country ID (LCID) be identical to the old library's LCID. Because the Microsoft Excel 5.0 Object Library has an LCID of 9 (English) and the Microsoft Excel 8.0 Object Library has an LCID of 0 (Default Language), this test fails; Microsoft Visual Basic 4.0x then displays the error:

"Object library's language setting incompatible with current project"

and does not add the new library to the Tools/Reference list.

<div class="resolution_section">

RESOLUTION
There are two workarounds: one affects all newly created projects; the other, the current project only.

NOTE 1: The underscore character (_) below is used as a line-continuation character and should not be typed. There should be no spaces between the character preceding the underscore and the letter on the next line.

NOTE 2: The references below presume that the directory containing Microsoft Office 97 for Windows is C:\OFFICE97 and that the pertinent Microsoft Excel 8.0 Object Library file, EXCEL8.OLB, is located in the directory C:\OFFICE97\OFFICE.

Method 1
This approach modifies Microsoft Visual Basic 4.0x's default project file so that the Microsoft Excel 8.0 Object Library will be available to all newly-created projects.

<ol> <li> In a text editor such as NOTEPAD.EXE, open the AUTO32LD.VBP project file, located in the Microsoft Visual Basic 4.0x directory. The file's contents will resemble the following: Object={F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.0#0; comdlg32.ocx Object={BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.0#0; tabctl32.ocx Object={3B7C8863-D78F-101B-B9B5-04021C009402}#1.0#0; richtx32.ocx Object={6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.0#0; comctl32.ocx Object={FAEEE763-117E-101B-8933-08002B2F4F5A}#1.0#0; dblist32.ocx Object={00028C01-0000-0000-0000-000000000046}#1.0#0; DBGRID32.OCX Object={F6125AB1-8AB1-11CE-A77F-08002B2F4E98}#1.0#0; msrdc32.ocx Reference=*\G{BEF6E001-A874-101A-8BBA-00AA00300CAB}#2.0#0#C:\WINDOWS\_ SYSTEM32\OLEPRO32.DLL#Standard OLE Types Reference=*\G{EE008642-64A8-11CE-920F-08002B369A33}#1.0#0#C:\WINDOWS\_ SYSTEM32\MSRDO32.dll#Microsoft Remote Data Object 1.0 Name="Project1" </li> <li> Add the line below: Reference=*\G{00020813-0000-0000-C000-000000000046}#1.2#0#C:\OFFICE97\_ OFFICE\EXCEL8.OLB#Microsoft Excel 8.0 Object Library so that the file appears as follows: Object={F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.0#0; comdlg32.ocx Object={BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.0#0; tabctl32.ocx Object={3B7C8863-D78F-101B-B9B5-04021C009402}#1.0#0; richtx32.ocx Object={6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.0#0; comctl32.ocx Object={FAEEE763-117E-101B-8933-08002B2F4F5A}#1.0#0; dblist32.ocx Object={00028C01-0000-0000-0000-000000000046}#1.0#0; DBGRID32.OCX Object={F6125AB1-8AB1-11CE-A77F-08002B2F4E98}#1.0#0; msrdc32.ocx Reference=*\G{BEF6E001-A874-101A-8BBA-00AA00300CAB}#2.0#0#C:\WINDOWS\_ SYSTEM32\OLEPRO32.DLL#Standard OLE Types Reference=*\G{EE008642-64A8-11CE-920F-08002B369A33}#1.0#0#C:\WINDOWS\_ SYSTEM32\MSRDO32.dll#Microsoft Remote Data Object 1.0 Reference=*\G{00020813-0000-0000-C000-000000000046}#1.2#0#C:\OFFICE97\_ OFFICE\EXCEL8.OLB#Microsoft Excel 8.0 Object Library Name="Project1" </li> <li>Save the AUTO32LD.VBP file and close the text editor.</li> <li>Start Microsoft Visual Basic 4.0x and select Tools, then References.</li> <li>The Microsoft Excel 5.0 Object Library no longer appears in the list. Instead, the Microsoft Excel 8.0 Object Library is available and checked for use.</li></ol>

Method 2
This technique modifies a given project's VBP file to include the Microsoft Excel 8.0 Object Library just for that project.

<ol> <li>Save and close the project with the Microsoft Excel 5.0 Object Library reference.</li> <li> In a text editor such as NOTEPAD.EXE, open the project's VBP file and change the reference to Microsoft Excel from: Reference=*\G{00020813-0000-0000-C000-000000000046}#1.0#9#C:\OFFICE97\_ OFFICE\XL5EN32.OLB#Microsoft Excel 5.0 Object Library to: Reference=*\G{00020813-0000-0000-C000-000000000046}#1.2#0#C:\OFFICE97\_ OFFICE\EXCEL8.OLB#Microsoft Excel 8.0 Object Library </li> <li>Save the project's VBP file and close the text editor.</li> <li>Start Microsoft Visual Basic 4.0x, and then load and save the project.</li> <li>Select Tools, then References. The Microsoft Excel 5.0 Object Library no longer appears in the list. Instead, the Microsoft Excel 8.0 Object Library is available and checked for use with this project. Newly- created projects will revert to the Microsoft Excel 5.0 Object Library.</li></ol>

<div class="status_section">

STATUS
Microsoft has confirmed this to be a bug in the versions of Microsoft Visual Basic listed at the beginning of this article.

<div class="moreinformation_section">

MORE INFORMATION
Microsoft Visual Basic 4.0x requires LCID consistency for a given object library's Globally Unique Identifier (GUID), even if the incoming object library's version number is different from the existing object library's version number. Both the Microsoft Excel 5.0 Object Library and the Microsoft Excel 8.0 Object Library share the same GUID, so this arbitrary LCID rule is enforced.

The behavior is particularly noticeable after installing Microsoft Office 97 to a machine containing both Microsoft Visual Basic 4.0x and one of the aforementioned earlier versions of Microsoft Office for Windows; the Microsoft Excel 8.0 Object Library is conspicuously absent from Microsoft Visual Basic 4.0x's Tools/Reference list, yet all of the other Microsoft Office 97 Object Libraries are shown (namely, those for Microsoft Office 8.0, Microsoft Access 8.0, Microsoft Binder 8.0, Microsoft Graph 8.0, Microsoft PowerPoint 8.0, and Microsoft Word 8.0).

Steps to Reproduce Problem
NOTE: The following presumes that Microsoft Visual Basic 4.0x, Microsoft Excel for Windows (5.0x or 7.0x), and Microsoft Excel 97 for Windows 8.0 have been installed.

<ol> <li>Start Microsoft Visual Basic 4.0x.</li> <li>For the new, default project, select Tools, then References, and choose the Microsoft Excel 5.0 Object Library. Click OK.</li> <li> On a Microsoft Visual Basic 4.0x form, create a CommandButton and type the code below into its click event: Private Sub cmdMakeMyChart_Click Dim xlchart As Chart Set xl = CreateObject("Excel.Application") xl.Visible = True xl.Workbooks.Add xl.Range("a1").Value = 1 xl.Range("a2").Value = 2 xl.Range("a3").Value = 3 xl.Range("a4").Formula = "=sum(a1:a3)" xl.Range("A1").CurrentRegion.Select Set xlchart = xl.Charts.Add xlchart.Type = xl3DColumn 'xlchart.ChartType = xlPyramidCol End Sub </li> <li>Run the code, click the CommandButton, and observe the instantiation of Microsoft Excel for Windows (5.0x or 7.0x) as an OLE automation server. A three-dimensional column chart of four values is created.</li> <li>Close Microsoft Excel without saving the resultant workbook.</li> <li> Now, move the apostrophe in the above code so that: xlchart.Type = xl3DColumn 'xlchart.ChartType = xlPyramidCol becomes: 'xlchart.Type = xl3DColumn xlchart.ChartType = xlPyramidCol </li></ol>

Because the pyramid chart is unique to Microsoft Excel 97 for Windows, a reference to the Microsoft Excel 8.0 Object Library is needed.

<ol> <li>Select Tools, then References, and note that even if you had done a complete install of Microsoft Office 97 for Windows (or Microsoft Excel 97 for Windows) subsequent to installing Microsoft Excel for Windows (5.0x or 7.0x) completely, the Microsoft Excel 8.0 Object Library is not listed (although the object libraries for Microsoft Office 8.0, Microsoft Access 8.0, Microsoft Binder 8.0, Microsoft Graph 8.0, Microsoft PowerPoint 8.0, and Microsoft Word 8.0 are listed).</li> <li>Click Browse and navigate to Microsoft Office 97's OFFICE directory (typically C:\OFFICE97\OFFICE).</li> <li>Double-click EXCEL8.OLB and note the error:

"Object library's language setting incompatible with current project"

</li> <li>Click OK. Deselecting "Microsoft Excel 5.0 Object Library" and trying to deselect "Visual Basic for Applications" does not allow EXCEL8.OLB to be added. The latter attempt produces the error:

"Can't remove control or reference: in use"

</li></ol>

Additional query words: OLE object type library automation server registry GUID LCID

Keywords: kberrmsg kbbug kbinterop kbautomation kbpending KB170356

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.