Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 279
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 279
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 279
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 279
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF AND MATCH data type issue EZ[_2_] Excel Worksheet Functions 2 June 18th 09 05:35 PM
Possible Data Type Issue shelfish Excel Programming 3 May 31st 08 11:18 PM
Variable Issue Mike H. Excel Programming 2 November 26th 07 05:01 PM
Variable type Alan Beban[_2_] Excel Programming 2 September 17th 07 06:13 PM
Type of variable J@Y Excel Programming 3 August 14th 07 04:14 PM


All times are GMT +1. The time now is 08:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"