# VBForums CodeBank > CodeBank - Visual Basic 6 and earlier >  VB6 - Module to launch IE

## bat711

I see a lot of people ask how to launch Internet Explorer to a specific web page.  Didn't find anything in the CodeBank so I thought I'd post the way I've been doing it.  The module contains some additional stuff for Windows Registry access as well.  

Basic operation would be to type LaunchIE(strURL).  LaunchIE is the function and strURL would be a string with a URL in it, pretty self explanatory.  Anyways, this module will access the registry for IE's path, then shell Internet Explorer and navigate to the specified site.  This particular way to launch IE also creates each IE as a separate process, which people may or may not find useful.  If you are doing anything where you need separate instances for separate user sessions this is will work.  There are about a million different ways to do this and this is just one.

The second one below is basically the same thing as above except it uses ShellExecute.  Only difference is that it uses the default browser which could be anything (FrontPage, Word, etc.) and it does not create separate instances of the browser. 

Questions, comments, concerns?  Leave a message.

----------


## thegreatone

The most simplistic way of doing this would be


VB Code:
Shell "C:\Program Files\Internet Explorer\IEXPLORE.EXE http://www.google.co.uk"

But the obvious advantage of the module is that it will search for the path if it is not situated in the default directory for whatever reason.

----------


## bat711

True, I just tried to make it so nothing was hardcoded and keep it portable.  It's also easy to use it as an object.  

It's just that what I've been using it for this wouldn't work since I'm logging into a secure site and if a user launches to the website twice I would have problems with cookies since the object only creates one process.

----------


## Hack

> The most simplistic way of doing this would be
> 
> 
> VB Code:
> Shell "C:\Program Files\Internet Explorer\IEXPLORE.EXE http://www.google.co.uk"
> 
> But the obvious advantage of the module is that it will search for the path if it is not situated in the default directory for whatever reason.


I perfer using the ShellExecute API do to this, but that is only because I've had Shell do some funky things.   If anyone is interested in how to use that API for opening a specific web page, you can do a search.  I've posted that code numerous times.

----------


## manavo11

I also prefer the ShellExecute API since it opens the default browser and you don't force the user to use IE  :Smilie:

----------


## Sir Loin

The easiest way to launch IE is 


VB Code:
dim IE as object
set IE = CreateObject("internetexplorer.application")
IE.visible = true
IE.navigate "URL HERE"

-Sir Loin

----------


## bat711

Sir Loin - Unfortunately launching IE as an object will not give some people the results they desire if the are using cookies or it's a secure site.  Launching through Shell or ShellExecute will create a new Internet Explorer Process each time you launch it.  With multiple threads running off of one IE process, cookies are shared, so if you need people to log in or identify themselves somehow it would create a bit of a security hole.

I'll add another version that uses ShellExecute and default browser.  -- *ADDED*

----------


## mregina

Sir Loin,

Any idea if I can tell IE.navigate to navigate to a specific URL that is written in a corresponding field? Say [tracking_url]?




> The easiest way to launch IE is 
> 
> 
> VB Code:
> dim IE as object
set IE = CreateObject("internetexplorer.application")
IE.visible = true
IE.navigate "URL HERE"
> 
> -Sir Loin

----------


## manavo11

How do you mean field? A database field? A textbox field?

Either way, you should be able to do this :


vb Code:
IE.navigate Text1.Text 'or the recordset field instead of the text1.text

----------


## mregina

Ah, therein lies the sag, I'm not that well versed in VB..all I know is that I have a record in my table with the full URL I want IE to navigate to...called 'tracking_url'..when I try to tell VB to open to the specified URL in tracking_url, it simply tries to open to http://tracking_url.. and a lovely error page obviously

----------


## sohaildotcom

dim IE as object
set IE = CreateObject("internetexplorer.application")
IE.visible = true
IE.navigate "URL HERE" 
the code is working but the only problem that i have here that everytime its open a new iexplorer ..

is there a code where i can define a iexplorer name like we do in html so all the website open in a same window
Regards
Sohail

----------


## manavo11

> dim IE as object
> set IE = CreateObject("internetexplorer.application")
> IE.visible = true
> IE.navigate "URL HERE" 
> the code is working but the only problem that i have here that everytime its open a new iexplorer ..
> 
> is there a code where i can define a iexplorer name like we do in html so all the website open in a same window
> Regards
> Sohail


If you declare the variable globally (Dim IE As Object) and not locally in a function, then you should be able to access it again and run the IE.navigate with a different URL.

----------


## sohaildotcom

> If you declare the variable globally (Dim IE As Object) and not locally in a function, then you should be able to access it again and run the IE.navigate with a different URL.


I didn't get that... i m sorry 

what i want the code so that i can opne all urls in a same iexplorer windows.
 if you could write me the code that would be great....

----------


## manavo11

Something like this I guess (untested):


vb Code:
Dim IE As Object Private Sub Form_Load()    Set IE = CreateObject("internetexplorer.application")    IE.visible = trueEnd Sub Private Sub Command1_Click()    IE.navigate Text1.TextEnd Sub

----------


## taedeen

Hi.. thanks for the tips, here is the code i used in the end pretty basic but effective.  Example here is a link from a Work order field( in this case just a cell with contents beginning WRQ.....) to the web page where the request is stored, reuses the internet page if available or launches new instance, although potential for looping via error routine, but havnt come accross situation yet




```
'Global Declares
 Dim ie As Object


Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal  Target As Range)
 On Error GoTo err_out


 If Target.Text <> "" And UCase(Mid(Trim(Target.Text), 1, 3)) = "WRQ" Then
  SrvNbr = Mid(Trim(Target.Text), 4, 7)
  UrlCde = "URL" & SrvNbr
  ie.navigate UrlCde
 End If

 Exit Sub

 err_out:
  'Create the IE Window if not running
  Set ie = CreateObject("internetexplorer.application")
  ie.Visible = True
  Resume
End Sub
```

----------

