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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compile error: User-defined type not defined (Dim as InternetExplorer)

Status
Not open for further replies.

ineedhelplease

Technical User
Dec 18, 2002
18
US
I am trying to use the getobject method to use the current open session of IE, but I receive an error on the following variable declariation:

Dim objIE As InternetExplorer

Compile error: User-defined type not defined

What do I need to do to be able to declare objIE as IE?

Thanks everyone for your help.



FYI here is the exact function:
--------------start--code---------------
Dim objIE As InternetExplorer
Dim iURL As String

iURL = "objIE = GetObject("InternetExplorer.Application")

With objIE
.Navigate iURL
End With

--------------end--code-----------------

Very simple function that I would like to use with an already open session of IE.
 
Why not simply this ?
Dim objIE As Object

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I tried the DIM as Object.

I can get the following code to work:
-----------------------start--code--
Dim objIE As Object
Dim iURL As String

iURL = "Set objIE = CreateObject("InternetExplorer.Application")

DoEvents

With objIE
.Visible = True
.Navigate iURL
End With
---------------------end--code--
but it opens a new IE session. I am trying to use a current IE session that was opened from a previous sub.

The following code is not working:
---------------------start--code--
Dim objIE As Object
Dim iURL As String

iURL = "Set objIE = GetObject("InternetExplorer.Application")

DoEvents

With objIE
.Visible = True
.Navigate iURL
End With
--------------------end--code--
I receive "Automation error Invalide syntax"

I read somewhere that I would need to define objIE not as an object but as InternetExplorer. I am willing to try anything to grab an open IE session.

thank you for your fast reply.
 
Set objIE = GetObject([!], [/!]"InternetExplorer.Application")

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks again for you quick reply. I tried to modify the code as you have suggested, but now I get another error:

"ActiveX component can't create object"

Any suggestions?

Again, thank you for your quick reply.
 
I am trying to use a current IE session that was opened from a previous sub
Why not reusing the same object defined as global ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top