Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Early variable type issue
My VBA is Microsoft Visual Basic 6.3, from Excel 2003 (11.6535.6360) SP1
from XP Professional Version 2002 SP3. I have been convinced to use Option Explicit in VBA. I have also been convinced to go for early typing. The code below uses late typing. I have Dim IE as Object Set IE = CreateObject("InternetExplorer.Application") The Set command changes the type of IE from Object to Object/WebBrowser2 "Dim IE as WebBrowser2" results in a "Compile error: User-defined type not defined". From reading past posts, I think Tools/References... could fix that. How can I find out where WebBrowser2 comes from? Is there any Basic code which sets references? I find Tools/References... a bit opaque. Ideally, any reference which is not explicitly specified would error. -- Walter Briscoe |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Early variable type issue
For me, it is Microsoft Internet Controls in References that needs checking.
That doesn't have WebBrowser2, only WebBrowser_V1, but then I still have IE6, none of these resource hungry later versions. -- __________________________________ HTH Bob "Walter Briscoe" wrote in message ... My VBA is Microsoft Visual Basic 6.3, from Excel 2003 (11.6535.6360) SP1 from XP Professional Version 2002 SP3. I have been convinced to use Option Explicit in VBA. I have also been convinced to go for early typing. The code below uses late typing. I have Dim IE as Object Set IE = CreateObject("InternetExplorer.Application") The Set command changes the type of IE from Object to Object/WebBrowser2 "Dim IE as WebBrowser2" results in a "Compile error: User-defined type not defined". From reading past posts, I think Tools/References... could fix that. How can I find out where WebBrowser2 comes from? Is there any Basic code which sets references? I find Tools/References... a bit opaque. Ideally, any reference which is not explicitly specified would error. -- Walter Briscoe |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Early variable type issue
Just to add - if 'Microsoft Internet Controls' not listed (often it isn't)
browse to SHDocVw.dll in your system folder. Depending on your version you might be able to do dim ie as IWebBrowser2 but try Dim ie As SHDocVw.InternetExplorer While developing, the Early Binding reference will help with all the intellisense. But if you are going to distribute probably better to remove the reference and adapt to Late Binding, Dim IE as Object. I have been convinced to use Option Explicit in VBA. that's good! Regards, Peter T "Walter Briscoe" wrote in message ... My VBA is Microsoft Visual Basic 6.3, from Excel 2003 (11.6535.6360) SP1 from XP Professional Version 2002 SP3. I have been convinced to use Option Explicit in VBA. I have also been convinced to go for early typing. The code below uses late typing. I have Dim IE as Object Set IE = CreateObject("InternetExplorer.Application") The Set command changes the type of IE from Object to Object/WebBrowser2 "Dim IE as WebBrowser2" results in a "Compile error: User-defined type not defined". From reading past posts, I think Tools/References... could fix that. How can I find out where WebBrowser2 comes from? Is there any Basic code which sets references? I find Tools/References... a bit opaque. Ideally, any reference which is not explicitly specified would error. -- Walter Briscoe |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Early variable type issue
In message of Thu, 16 Jul 2009
14:25:48 in microsoft.public.excel.programming, Bob Phillips writes For me, it is Microsoft Internet Controls in References that needs checking. That doesn't have WebBrowser2, only WebBrowser_V1, but then I still have IE6, none of these resource hungry later versions. Thanks for trying to help. Why does that work for you? I know you know it works. I don't know what process is involved in getting there. Although I don't have Microsoft Internet Controls in References (either checked/unchecked), some magical process maps "InternetExplorer.Application" to the relevant type library. ( I think that's what it does, anyway. ;) -- Walter Briscoe |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Early variable type issue
In message of Thu, 16 Jul 2009
15:18:56 in microsoft.public.excel.programming, Peter T <peter_t@discuss ions.?.invalid writes Thanks for trying to shine light. Just to add - if 'Microsoft Internet Controls' not listed (often it isn't) It is absent from the list in my Tools/References... browse to SHDocVw.dll in your system folder. I infer you mean the system32 folder. How do you know (other than using experience I lack) that that is the relevant file? What should I do once I have found SHDocVw.dll? Depending on your version you might be able to do dim ie as IWebBrowser2 but try Dim ie As SHDocVw.InternetExplorer Both complain the type is not defined. While developing, the Early Binding reference will help with all the intellisense. But if you are going to distribute probably better to remove the reference and adapt to Late Binding, Dim IE as Object. I assume the reason is to allow end users' systems to find something that matches, rather than being excessively prescriptive. I have been convinced to use Option Explicit in VBA. that's good! Regards, Peter T "Walter Briscoe" wrote in message ... My VBA is Microsoft Visual Basic 6.3, from Excel 2003 (11.6535.6360) SP1 from XP Professional Version 2002 SP3. I have been convinced to use Option Explicit in VBA. I have also been convinced to go for early typing. The code below uses late typing. I have Dim IE as Object Set IE = CreateObject("InternetExplorer.Application") The Set command changes the type of IE from Object to Object/WebBrowser2 "Dim IE as WebBrowser2" results in a "Compile error: User-defined type not defined". From reading past posts, I think Tools/References... could fix that. How can I find out where WebBrowser2 comes from? Is there any Basic code which sets references? I find Tools/References... a bit opaque. Ideally, any reference which is not explicitly specified would error. -- Walter Briscoe -- Walter Briscoe |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Early variable type issue
"Walter Briscoe" wrote in message
Thanks for trying to shine light. Just to add - if 'Microsoft Internet Controls' not listed (often it isn't) It is absent from the list in my Tools/References... as I said, often it isn't (ie not in the list), hence browse browse to SHDocVw.dll in your system folder. I infer you mean the system32 folder. Er, yes (typically unless NT) How do you know (other than using experience I lack) that that is the relevant file? pass, but that's the one you want What should I do once I have found SHDocVw.dll? Browse from the button in the References dialog. Select it and it should then appear in the list of references as 'Microsoft Internet Controls', think that also ticks it and adds as a reference to the project, if not find it in the list and tick it. Depending on your version you might be able to do dim ie as IWebBrowser2 but try Dim ie As SHDocVw.InternetExplorer Both complain the type is not defined. Because you haven't added the reference yet Once added as a reference look at the SHDocVw library in Object Browser, F2 While developing, the Early Binding reference will help with all the intellisense. But if you are going to distribute probably better to remove the reference and adapt to Late Binding, Dim IE as Object. I assume the reason is to allow end users' systems to find something that matches, rather than being excessively prescriptive. I have been convinced to use Option Explicit in VBA. that's good! -- Walter Briscoe Peter T |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Early variable type issue
PS
While developing, the Early Binding reference will help with all the intellisense. But if you are going to distribute probably better to remove the reference and adapt to Late Binding, Dim IE as Object. I assume the reason is to allow end users' systems to find something that matches, rather than being excessively prescriptive. If you have IE7 installed and send the file to a user with say IE6, things might go wrong. Not sure with IE but in general never send a reference to a library that might be newer than that on the user's system. If in doubt convert to Late Binding when done and before distributing. Remove the reference, change all relevant object declarations to As Object, change any named constants to their intrinsic values. If you have Option Explicit heading all modules, Debug/compile will flag anything you've over looked. Peter T |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Early variable type issue
On Thu, 16 Jul 2009 13:20:30 +0100, Walter Briscoe
wrote: My VBA is Microsoft Visual Basic 6.3, from Excel 2003 (11.6535.6360) SP1 from XP Professional Version 2002 SP3. I have been convinced to use Option Explicit in VBA. I have also been convinced to go for early typing. The code below uses late typing. I have Dim IE as Object Set IE = CreateObject("InternetExplorer.Application") The Set command changes the type of IE from Object to Object/WebBrowser2 "Dim IE as WebBrowser2" results in a "Compile error: User-defined type not defined". From reading past posts, I think Tools/References... could fix that. How can I find out where WebBrowser2 comes from? Is there any Basic code which sets references? I find Tools/References... a bit opaque. Ideally, any reference which is not explicitly specified would error. You should have a reference to: "Microsoft Internet Controls". If not, see if you have "Microsoft Browser Helpers". If you have the latter, and set the reference, it changes to the former :-| If not, try browsing to C:\WINDOWS\system32\shdocvw.dll or C:\WINDOWS\system32\ieframe.dll --ron |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
Early variable type issue
In message of Thu, 16 Jul 2009
13:20:30 in microsoft.public.excel.programming, Walter Briscoe writes My VBA is Microsoft Visual Basic 6.3, from Excel 2003 (11.6535.6360) SP1 from XP Professional Version 2002 SP3. I have been convinced to use Option Explicit in VBA. I have also been convinced to go for early typing. The code below uses late typing. I have Dim IE as Object Set IE = CreateObject("InternetExplorer.Application") The Set command changes the type of IE from Object to Object/WebBrowser2 "Dim IE as WebBrowser2" results in a "Compile error: User-defined type not defined". From reading past posts, I think Tools/References... could fix that. How can I find out where WebBrowser2 comes from? Is there any Basic code which sets references? I find Tools/References... a bit opaque. Ideally, any reference which is not explicitly specified would error. Answering my own post seems the easiest place to hang the conclusion. I conclude there is no easy way to do what I was interested in doing. I confused people by being too specific with me example. I have a late binding variable, declared with Dim foo as Object. This is given a late binding type with Set foo = ArbitraryOperation(). That type can be seen in the Local Variables debugger window. There does not seem to be any way of going from that type to get to the data that needs to be selected by Tools\Reference... I find this strange as the underlying engine must effect such a process. Having been given the answer, but not the process, for IWebBrowser2, I failed to find the answer for HTMLDocument. I don't want to be told where to find HTMLDocument; I want to find out how to find HTMLDocument. Any technique needs to work for a reasonably large subset of types. Incidentally, the debugger uses a proportional font to display types. How are its fonts selected? The glyph for I is so slight I missed it in "IWebBrowser2". Courier may be ugly, but is useful for small amounts of arbitrary characters. It may be the granularity of selection is so coarse that I have to live with the result. -- Walter Briscoe |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
Early variable type issue
On Thu, 23 Jul 2009 08:31:55 +0100, Walter Briscoe
wrote: I don't want to be told where to find HTMLDocument; I want to find out how to find HTMLDocument. Any technique needs to work for a reasonably large subset of types. I used Google. It helped me locate not only the relevant reference, but also pointed towards some other tips on usage. The one's I looked for were ultimately discussed on a Microsoft web site. --ron |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
IF AND MATCH data type issue | Excel Worksheet Functions | |||
Possible Data Type Issue | Excel Programming | |||
Variable Issue | Excel Programming | |||
Variable type | Excel Programming | |||
Type of variable | Excel Programming |