Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding Excel library gives puzzling "type mismatch" error 1

Status
Not open for further replies.

fsteeman

Programmer
Jul 17, 2002
103
DK
Hello all,

OK, this is so weird that I am wondering whether it's a bug in VB6....

I am using a custom made application for my job that I can change at will and that has grown pretty big. Recently, I wanted to add a routine that could read excel files. However, whenever I try to add the Reference to the MS Excel 9.0 library, I cannot run the program anymore because VB suddenly reports a "type mismatch" error in the following routine:


Sub AskForBut()
Dim buttt As Button
For Each buttt In ToolToggle.Buttons
If buttt.Value = tbrPressed Then MakeTree buttt.Key: Exit For
Next buttt
End Sub


But these things have nothing to do with one another! How can there suddenly be an error when before things were fine, only because I added a reference?!

Is it a question of homonymy with some variables/functions in the Excel library?
 
>Is it a question of homonymy

Yes, it is. Following aesseal's advice should address the issue.
 
Ok I tried that, but now a "User-defined type not defined" error is reported!

Trying: Dim buttt as Toolbar.Button, does not help either (ToolToggle is how the Toolbar control is named). I get a Type mismatch again...

 
Button, Toolbar and ToolbarButton are a part of hidden objects in excel. They disappeared with excel 95, but left hidden for backward compatibility. Maybe this is confusing.
Have you tried:
Dim buttt As MSComctlLib.Button

combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top