Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Have come across a strange problem today with one of my customers.
In a .xla add-in I have in very much simplified code the following: Sub test() Dim l As Long l = GiveString() MsgBox l End Sub Function GiveString() As String Dim s As String s = "1" GiveString = s End Function All this works fine on my 2 home PC's with XL11 and XL9. With this one customer though in XL9 there is the error: Type mismatch. Why would this be if it runs fine on the home machine with XL9? RBS |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I suspect the customer actually is experiencing this in xl97 (xl8). In xl97,
you would get that error. -- Regards, Tom Ogilvy "RB Smissaert" wrote: Have come across a strange problem today with one of my customers. In a .xla add-in I have in very much simplified code the following: Sub test() Dim l As Long l = GiveString() MsgBox l End Sub Function GiveString() As String Dim s As String s = "1" GiveString = s End Function All this works fine on my 2 home PC's with XL11 and XL9. With this one customer though in XL9 there is the error: Type mismatch. Why would this be if it runs fine on the home machine with XL9? RBS |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Just to add the example works fine in both my XL97 and XL2000, as does the
following in both versions Dim n As Long n = "123" Regards, Peter T "Tom Ogilvy" wrote in message ... I suspect the customer actually is experiencing this in xl97 (xl8). In xl97, you would get that error. -- Regards, Tom Ogilvy "RB Smissaert" wrote: Have come across a strange problem today with one of my customers. In a .xla add-in I have in very much simplified code the following: Sub test() Dim l As Long l = GiveString() MsgBox l End Sub Function GiveString() As String Dim s As String s = "1" GiveString = s End Function All this works fine on my 2 home PC's with XL11 and XL9. With this one customer though in XL9 there is the error: Type mismatch. Why would this be if it runs fine on the home machine with XL9? RBS |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Actually the non-simplified code is:
'error he If Val(ReadINIValueL(strINIPath, _ "Add-in behaviour", _ "F2 for load add-in")) = 0 Then Function ReadINIValueL(ByVal strINIPath As String, _ ByVal strHeader As String, _ ByVal strKey As String) As String Dim buf As String * 256 Dim Length As Long If Len(Dir(strINIPath)) = 0 Then ReadINIValueL = "<no file" Exit Function End If Length = GetPrivateProfileString(strHeader, _ strKey, _ "<no value", _ buf, _ Len(buf), _ strINIPath) ReadINIValueL = Left(buf, Length) End Function And the result of the function was "1" and not "<no file" or "<no value" RBS "Peter T" <peter_t@discussions wrote in message ... Just to add the example works fine in both my XL97 and XL2000, as does the following in both versions Dim n As Long n = "123" Regards, Peter T "Tom Ogilvy" wrote in message ... I suspect the customer actually is experiencing this in xl97 (xl8). In xl97, you would get that error. -- Regards, Tom Ogilvy "RB Smissaert" wrote: Have come across a strange problem today with one of my customers. In a .xla add-in I have in very much simplified code the following: Sub test() Dim l As Long l = GiveString() MsgBox l End Sub Function GiveString() As String Dim s As String s = "1" GiveString = s End Function All this works fine on my 2 home PC's with XL11 and XL9. With this one customer though in XL9 there is the error: Type mismatch. Why would this be if it runs fine on the home machine with XL9? RBS |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If I follow, effectively it does this (without the Val)
If "1" = 0 Then again this works in both my XL97 & XL2k Any missing references ? Regards, Peter T "RB Smissaert" wrote in message ... Actually the non-simplified code is: 'error he If Val(ReadINIValueL(strINIPath, _ "Add-in behaviour", _ "F2 for load add-in")) = 0 Then Function ReadINIValueL(ByVal strINIPath As String, _ ByVal strHeader As String, _ ByVal strKey As String) As String Dim buf As String * 256 Dim Length As Long If Len(Dir(strINIPath)) = 0 Then ReadINIValueL = "<no file" Exit Function End If Length = GetPrivateProfileString(strHeader, _ strKey, _ "<no value", _ buf, _ Len(buf), _ strINIPath) ReadINIValueL = Left(buf, Length) End Function And the result of the function was "1" and not "<no file" or "<no value" RBS "Peter T" <peter_t@discussions wrote in message ... Just to add the example works fine in both my XL97 and XL2000, as does the following in both versions Dim n As Long n = "123" Regards, Peter T "Tom Ogilvy" wrote in message ... I suspect the customer actually is experiencing this in xl97 (xl8). In xl97, you would get that error. -- Regards, Tom Ogilvy "RB Smissaert" wrote: Have come across a strange problem today with one of my customers. In a .xla add-in I have in very much simplified code the following: Sub test() Dim l As Long l = GiveString() MsgBox l End Sub Function GiveString() As String Dim s As String s = "1" GiveString = s End Function All this works fine on my 2 home PC's with XL11 and XL9. With this one customer though in XL9 there is the error: Type mismatch. Why would this be if it runs fine on the home machine with XL9? RBS |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Peter,
I don't think missing references are the problem as this happens very early in the code in the wb open event. I add references to the project dynamically, but that happens later on. I can see though that missing references are a suspect if you say that If "1" = 0 works on 97. I went through the registry with this customer and Excel\Options was only under HKEY_CURRENT_USER\Software\Microsoft\Office\9.0\ So I think it is Excel 9. RBS "Peter T" <peter_t@discussions wrote in message ... If I follow, effectively it does this (without the Val) If "1" = 0 Then again this works in both my XL97 & XL2k Any missing references ? Regards, Peter T "RB Smissaert" wrote in message ... Actually the non-simplified code is: 'error he If Val(ReadINIValueL(strINIPath, _ "Add-in behaviour", _ "F2 for load add-in")) = 0 Then Function ReadINIValueL(ByVal strINIPath As String, _ ByVal strHeader As String, _ ByVal strKey As String) As String Dim buf As String * 256 Dim Length As Long If Len(Dir(strINIPath)) = 0 Then ReadINIValueL = "<no file" Exit Function End If Length = GetPrivateProfileString(strHeader, _ strKey, _ "<no value", _ buf, _ Len(buf), _ strINIPath) ReadINIValueL = Left(buf, Length) End Function And the result of the function was "1" and not "<no file" or "<no value" RBS "Peter T" <peter_t@discussions wrote in message ... Just to add the example works fine in both my XL97 and XL2000, as does the following in both versions Dim n As Long n = "123" Regards, Peter T "Tom Ogilvy" wrote in message ... I suspect the customer actually is experiencing this in xl97 (xl8). In xl97, you would get that error. -- Regards, Tom Ogilvy "RB Smissaert" wrote: Have come across a strange problem today with one of my customers. In a .xla add-in I have in very much simplified code the following: Sub test() Dim l As Long l = GiveString() MsgBox l End Sub Function GiveString() As String Dim s As String s = "1" GiveString = s End Function All this works fine on my 2 home PC's with XL11 and XL9. With this one customer though in XL9 there is the error: Type mismatch. Why would this be if it runs fine on the home machine with XL9? RBS |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This doesn't have any bearing on Bart's non-simplified code, but
I don't have xl97 handy to test, but try it this way. this works in xl2003 but I believe it will raise typemismatch in xl97. Sub test() Dim i As Long i = 1 if i = GiveString() then msgbox "match" else MsgBox i end if End Sub Function GiveString() As String Dim s As String s = "1" GiveString = s End Function -- Regards, Tom Ogilvy "Peter T" wrote: Just to add the example works fine in both my XL97 and XL2000, as does the following in both versions Dim n As Long n = "123" Regards, Peter T "Tom Ogilvy" wrote in message ... I suspect the customer actually is experiencing this in xl97 (xl8). In xl97, you would get that error. -- Regards, Tom Ogilvy "RB Smissaert" wrote: Have come across a strange problem today with one of my customers. In a .xla add-in I have in very much simplified code the following: Sub test() Dim l As Long l = GiveString() MsgBox l End Sub Function GiveString() As String Dim s As String s = "1" GiveString = s End Function All this works fine on my 2 home PC's with XL11 and XL9. With this one customer though in XL9 there is the error: Type mismatch. Why would this be if it runs fine on the home machine with XL9? RBS |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sorry, the actual code was causing the error was:
If ReadINIValueL(strINIPath, _ "Add-in behaviour", _ "F2 for load add-in") = 0 Then So, without the Val. I had added the Val as a fix. So, your example looks very similar and probably this is indeed an XL97 thing. RBS "Tom Ogilvy" wrote in message ... This doesn't have any bearing on Bart's non-simplified code, but I don't have xl97 handy to test, but try it this way. this works in xl2003 but I believe it will raise typemismatch in xl97. Sub test() Dim i As Long i = 1 if i = GiveString() then msgbox "match" else MsgBox i end if End Sub Function GiveString() As String Dim s As String s = "1" GiveString = s End Function -- Regards, Tom Ogilvy "Peter T" wrote: Just to add the example works fine in both my XL97 and XL2000, as does the following in both versions Dim n As Long n = "123" Regards, Peter T "Tom Ogilvy" wrote in message ... I suspect the customer actually is experiencing this in xl97 (xl8). In xl97, you would get that error. -- Regards, Tom Ogilvy "RB Smissaert" wrote: Have come across a strange problem today with one of my customers. In a .xla add-in I have in very much simplified code the following: Sub test() Dim l As Long l = GiveString() MsgBox l End Sub Function GiveString() As String Dim s As String s = "1" GiveString = s End Function All this works fine on my 2 home PC's with XL11 and XL9. With this one customer though in XL9 there is the error: Type mismatch. Why would this be if it runs fine on the home machine with XL9? RBS |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
That also works in my XL 97, I got "match". I don't recall this particular
type of coercion not working in XL97. ?"1" = 1& True Regards, Peter T "Tom Ogilvy" wrote in message ... This doesn't have any bearing on Bart's non-simplified code, but I don't have xl97 handy to test, but try it this way. this works in xl2003 but I believe it will raise typemismatch in xl97. Sub test() Dim i As Long i = 1 if i = GiveString() then msgbox "match" else MsgBox i end if End Sub Function GiveString() As String Dim s As String s = "1" GiveString = s End Function -- Regards, Tom Ogilvy "Peter T" wrote: Just to add the example works fine in both my XL97 and XL2000, as does the following in both versions Dim n As Long n = "123" Regards, Peter T "Tom Ogilvy" wrote in message ... I suspect the customer actually is experiencing this in xl97 (xl8). In xl97, you would get that error. -- Regards, Tom Ogilvy "RB Smissaert" wrote: Have come across a strange problem today with one of my customers. In a .xla add-in I have in very much simplified code the following: Sub test() Dim l As Long l = GiveString() MsgBox l End Sub Function GiveString() As String Dim s As String s = "1" GiveString = s End Function All this works fine on my 2 home PC's with XL11 and XL9. With this one customer though in XL9 there is the error: Type mismatch. Why would this be if it runs fine on the home machine with XL9? RBS |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub aaa()
ActiveCell.Value = "a" If ActiveCell.Value = 1 Then MsgBox "Equals 1" Else MsgBox "Doesn't equal 1" End If End Sub Fails in xl97 with a type mismatch, but works in xl2002, xl2000 (at least for me) I don't know all the combinations that will cause it to fail in xl97 and not xl2000/2 but I know xl97 is more sensitive to this. May have no bearing on Bart's problem, but then again maybe it does. -- Regards, Tom Ogilvy "Peter T" <peter_t@discussions wrote in message ... That also works in my XL 97, I got "match". I don't recall this particular type of coercion not working in XL97. ?"1" = 1& True Regards, Peter T "Tom Ogilvy" wrote in message ... This doesn't have any bearing on Bart's non-simplified code, but I don't have xl97 handy to test, but try it this way. this works in xl2003 but I believe it will raise typemismatch in xl97. Sub test() Dim i As Long i = 1 if i = GiveString() then msgbox "match" else MsgBox i end if End Sub Function GiveString() As String Dim s As String s = "1" GiveString = s End Function -- Regards, Tom Ogilvy "Peter T" wrote: Just to add the example works fine in both my XL97 and XL2000, as does the following in both versions Dim n As Long n = "123" Regards, Peter T "Tom Ogilvy" wrote in message ... I suspect the customer actually is experiencing this in xl97 (xl8). In xl97, you would get that error. -- Regards, Tom Ogilvy "RB Smissaert" wrote: Have come across a strange problem today with one of my customers. In a .xla add-in I have in very much simplified code the following: Sub test() Dim l As Long l = GiveString() MsgBox l End Sub Function GiveString() As String Dim s As String s = "1" GiveString = s End Function All this works fine on my 2 home PC's with XL11 and XL9. With this one customer though in XL9 there is the error: Type mismatch. Why would this be if it runs fine on the home machine with XL9? RBS |
#11
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Maybe it was XL 8. Will find out tomorrow.
For now I have added Val to the string variables as with that it seems fine, even on this customer's PC. So: l = Val(GiveString()) RBS "Tom Ogilvy" wrote in message ... I suspect the customer actually is experiencing this in xl97 (xl8). In xl97, you would get that error. -- Regards, Tom Ogilvy "RB Smissaert" wrote: Have come across a strange problem today with one of my customers. In a .xla add-in I have in very much simplified code the following: Sub test() Dim l As Long l = GiveString() MsgBox l End Sub Function GiveString() As String Dim s As String s = "1" GiveString = s End Function All this works fine on my 2 home PC's with XL11 and XL9. With this one customer though in XL9 there is the error: Type mismatch. Why would this be if it runs fine on the home machine with XL9? RBS |
#12
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Can comfirm now that this was on Excel 9 (2000), so maybe the trouble
is somehow caused by a missing reference. Strange though that when I was debugging over the phone adding Val fixed at least the error on that line. RBS RB Smissaert wrote: Maybe it was XL 8. Will find out tomorrow. For now I have added Val to the string variables as with that it seems fine, even on this customer's PC. So: l = Val(GiveString()) RBS "Tom Ogilvy" wrote in message ... I suspect the customer actually is experiencing this in xl97 (xl8). In xl97, you would get that error. -- Regards, Tom Ogilvy "RB Smissaert" wrote: Have come across a strange problem today with one of my customers. In a .xla add-in I have in very much simplified code the following: Sub test() Dim l As Long l = GiveString() MsgBox l End Sub Function GiveString() As String Dim s As String s = "1" GiveString = s End Function All this works fine on my 2 home PC's with XL11 and XL9. With this one customer though in XL9 there is the error: Type mismatch. Why would this be if it runs fine on the home machine with XL9? RBS |
#13
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm sure you've double checked but if the string returns an extra non
numeric character, perhaps non-printable & not obvious, it would be fixed with use of Val. String functions are particularly sensitive to missing references. Although one is not used directly maybe a string function is used invisibly to perform the coercion, I don't know. I'm not sure that upgrading to 2003 will guarantee to fix the problem. Regards, Peter T wrote in message oups.com... Can comfirm now that this was on Excel 9 (2000), so maybe the trouble is somehow caused by a missing reference. Strange though that when I was debugging over the phone adding Val fixed at least the error on that line. RBS RB Smissaert wrote: Maybe it was XL 8. Will find out tomorrow. For now I have added Val to the string variables as with that it seems fine, even on this customer's PC. So: l = Val(GiveString()) RBS "Tom Ogilvy" wrote in message ... I suspect the customer actually is experiencing this in xl97 (xl8). In xl97, you would get that error. -- Regards, Tom Ogilvy "RB Smissaert" wrote: Have come across a strange problem today with one of my customers. In a .xla add-in I have in very much simplified code the following: Sub test() Dim l As Long l = GiveString() MsgBox l End Sub Function GiveString() As String Dim s As String s = "1" GiveString = s End Function All this works fine on my 2 home PC's with XL11 and XL9. With this one customer though in XL9 there is the error: Type mismatch. Why would this be if it runs fine on the home machine with XL9? RBS |
#14
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Yes, good point, but the result of that ini function in that particular case
only can be "1" or "0". Must admit though I haven't seen the actual return when it runs. As this customer has XL9 the whole issue of Type mismatch in XL8 versus 9 is now irrelevant and I will have to look somewhere else. Had a look in my customer database and I have nobody on XL8, so maybe I can throw all those Val's out again. My guess is that indeed it somehow has to do with references. Will have to wait till next week to find out. RBS "Peter T" <peter_t@discussions wrote in message ... I'm sure you've double checked but if the string returns an extra non numeric character, perhaps non-printable & not obvious, it would be fixed with use of Val. String functions are particularly sensitive to missing references. Although one is not used directly maybe a string function is used invisibly to perform the coercion, I don't know. I'm not sure that upgrading to 2003 will guarantee to fix the problem. Regards, Peter T wrote in message oups.com... Can comfirm now that this was on Excel 9 (2000), so maybe the trouble is somehow caused by a missing reference. Strange though that when I was debugging over the phone adding Val fixed at least the error on that line. RBS RB Smissaert wrote: Maybe it was XL 8. Will find out tomorrow. For now I have added Val to the string variables as with that it seems fine, even on this customer's PC. So: l = Val(GiveString()) RBS "Tom Ogilvy" wrote in message ... I suspect the customer actually is experiencing this in xl97 (xl8). In xl97, you would get that error. -- Regards, Tom Ogilvy "RB Smissaert" wrote: Have come across a strange problem today with one of my customers. In a .xla add-in I have in very much simplified code the following: Sub test() Dim l As Long l = GiveString() MsgBox l End Sub Function GiveString() As String Dim s As String s = "1" GiveString = s End Function All this works fine on my 2 home PC's with XL11 and XL9. With this one customer though in XL9 there is the error: Type mismatch. Why would this be if it runs fine on the home machine with XL9? RBS |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Type mismatch problem | Excel Programming | |||
Data Type Problem!!! | Excel Programming | |||
Data Type Problem? | Excel Discussion (Misc queries) | |||
Data type problem - ODBC Excel '97-2000 Driver | Excel Programming | |||
Excel VBA - Data Type Conversion problem | Excel Programming |