PC Review Forums Newsgroups Microsoft Access Microsoft Access VBA Modules Open Web browser with code

Reply

Open Web browser with code

 
Thread Tools Rate Thread
Old 04-08-2003, 06:20 PM   #1
Lisa B.
Guest
 
Posts: n/a
Default Open Web browser with code


Does anyone know the code to open the web browser and go to a URL listed in
a field.

I know I can do it if I make the field a hyperlink, but the field is on a
sub form and will be invisible to the user.


  Reply With Quote
Old 04-08-2003, 06:33 PM   #2
Guest
 
Posts: n/a
Default Re: Open Web browser with code

Lisa,

Using the Microsoft Web Browser object, in the click event of a button, the
following works:


Dim ctl As Object
Dim var As Long

Set ctl = Me.ctlWebBrowser.Object

ctl.Navigate ("www.google.com")


While you're at it, you can test for and use the Updated event and run code
if required:

Private Sub ctlWebBrowser_Updated(Code As Integer)
Me.Command1.Visible = True
Me.Command1.SetFocus
End Sub

Use the Object Browser to inspect all the events and properties.

Steve



"Lisa B." <lbagley@MayaTech.com> wrote in message
news:%23U2iIRqWDHA.2476@tk2msftngp13.phx.gbl...
> Does anyone know the code to open the web browser and go to a URL listed

in
> a field.
>
> I know I can do it if I make the field a hyperlink, but the field is on a
> sub form and will be invisible to the user.
>
>



  Reply With Quote
Old 04-08-2003, 06:43 PM   #3
Guest
 
Posts: n/a
Default Re: Open Web browser with code

Occurs to me I may have missed your question. I was thinking of the browser
object inserted on a form...

In code this works to start IE and go to 'www.msn.com':

Shell "C:\Program Files\Internet Explorer\iexplore.exe www.msn.com"

Steve

<SteveT> wrote in message news:%23JC8daqWDHA.1680@tk2msftngp13.phx.gbl...
> Lisa,
>
> Using the Microsoft Web Browser object, in the click event of a button,

the
> following works:
>
>
> Dim ctl As Object
> Dim var As Long
>
> Set ctl = Me.ctlWebBrowser.Object
>
> ctl.Navigate ("www.google.com")
>
>
> While you're at it, you can test for and use the Updated event and run

code
> if required:
>
> Private Sub ctlWebBrowser_Updated(Code As Integer)
> Me.Command1.Visible = True
> Me.Command1.SetFocus
> End Sub
>
> Use the Object Browser to inspect all the events and properties.
>
> Steve
>
>
>
> "Lisa B." <lbagley@MayaTech.com> wrote in message
> news:%23U2iIRqWDHA.2476@tk2msftngp13.phx.gbl...
> > Does anyone know the code to open the web browser and go to a URL listed

> in
> > a field.
> >
> > I know I can do it if I make the field a hyperlink, but the field is on

a
> > sub form and will be invisible to the user.
> >
> >

>
>



  Reply With Quote
Old 04-08-2003, 07:05 PM   #4
Guest
 
Posts: n/a
Default Re: Open Web browser with code

Here's another approach:

www.mvps.org/access/modules/mdl0062.htm

Steve


<SteveT> wrote in message news:%23JC8daqWDHA.1680@tk2msftngp13.phx.gbl...
> Lisa,
>
> Using the Microsoft Web Browser object, in the click event of a button,

the
> following works:
>
>
> Dim ctl As Object
> Dim var As Long
>
> Set ctl = Me.ctlWebBrowser.Object
>
> ctl.Navigate ("www.google.com")
>
>
> While you're at it, you can test for and use the Updated event and run

code
> if required:
>
> Private Sub ctlWebBrowser_Updated(Code As Integer)
> Me.Command1.Visible = True
> Me.Command1.SetFocus
> End Sub
>
> Use the Object Browser to inspect all the events and properties.
>
> Steve
>
>
>
> "Lisa B." <lbagley@MayaTech.com> wrote in message
> news:%23U2iIRqWDHA.2476@tk2msftngp13.phx.gbl...
> > Does anyone know the code to open the web browser and go to a URL listed

> in
> > a field.
> >
> > I know I can do it if I make the field a hyperlink, but the field is on

a
> > sub form and will be invisible to the user.
> >
> >

>
>



  Reply With Quote
Old 04-08-2003, 07:28 PM   #5
Tim Ferguson
Guest
 
Posts: n/a
Default Re: Open Web browser with code

<SteveT> wrote in news:eb5MbgqWDHA.2360@TK2MSFTNGP12.phx.gbl:

>
> Shell "C:\Program Files\Internet Explorer\iexplore.exe www.msn.com"
>
>


Curious -- putting a well formed URI into the Start Programs/ Run box like
this works as expected:-

http://www.helios.com

but using the same thing as a shell command results in a file not found
error.

? shell( "http://www.helios.com" )

So what is the correct procedure for calling the _default_ browser without
having to hard-code the path and executable?

Tim F

  Reply With Quote
Old 04-08-2003, 07:49 PM   #6
Lisa B.
Guest
 
Posts: n/a
Default Re: Open Web browser with code

OK, that works. However when IE opens it is minimized to the startbar. Is
there a way to have it open as the active window?

Now, I have this code behind a button
----------------------------------------------------------------
Dim URLAddress As String

GL_Address =
Forms![frmRecruitment]![frmAppointment].Form![frmAppointmentLocation].Form![
Address]
GL_City =
Forms![frmRecruitment]![frmAppointment].Form![frmAppointmentLocation].Form![
City]
GL_State = Me![frmAppointmentLocation].Form![StateID]
GL_Zip = Me![frmAppointmentLocation].Form![Zip]

MapAddress = ChangeStr(GL_Address, Chr$(32), Chr$(43), 0)
MapCity = ChangeStr(GL_City, Chr$(32), Chr$(43), 0)

URLAddress =
"http://www.mapquest.com/maps/map.adp?country=US&addtohistory=&address=" +
MapAddress + "state=" + GL_State + "&zipcode=" + GL_Zip +
"&homesubmit=Get+Map"

Shell "C:\Program Files\Internet Explorer\iexplore.exe " & URLAddress
--------------------------------------------------------------------------

This opens IE to mapquest and finds an address






<SteveT> wrote in message news:eb5MbgqWDHA.2360@TK2MSFTNGP12.phx.gbl...
> Occurs to me I may have missed your question. I was thinking of the

browser
> object inserted on a form...
>
> In code this works to start IE and go to 'www.msn.com':
>
> Shell "C:\Program Files\Internet Explorer\iexplore.exe www.msn.com"
>
> Steve
>
> <SteveT> wrote in message news:%23JC8daqWDHA.1680@tk2msftngp13.phx.gbl...
> > Lisa,
> >
> > Using the Microsoft Web Browser object, in the click event of a button,

> the
> > following works:
> >
> >
> > Dim ctl As Object
> > Dim var As Long
> >
> > Set ctl = Me.ctlWebBrowser.Object
> >
> > ctl.Navigate ("www.google.com")
> >
> >
> > While you're at it, you can test for and use the Updated event and run

> code
> > if required:
> >
> > Private Sub ctlWebBrowser_Updated(Code As Integer)
> > Me.Command1.Visible = True
> > Me.Command1.SetFocus
> > End Sub
> >
> > Use the Object Browser to inspect all the events and properties.
> >
> > Steve
> >
> >
> >
> > "Lisa B." <lbagley@MayaTech.com> wrote in message
> > news:%23U2iIRqWDHA.2476@tk2msftngp13.phx.gbl...
> > > Does anyone know the code to open the web browser and go to a URL

listed
> > in
> > > a field.
> > >
> > > I know I can do it if I make the field a hyperlink, but the field is

on
> a
> > > sub form and will be invisible to the user.
> > >
> > >

> >
> >

>
>



  Reply With Quote
Old 04-08-2003, 09:36 PM   #7
Guest
 
Posts: n/a
Default Re: Open Web browser with code


Try:

Shell "C:\Program Files\Internet Explorer\iexplore.exe " & URLAddress
,vbMaximizedFocus



"Lisa B." <lbagley@MayaTech.com> wrote in message
news:%231mpJDrWDHA.1736@TK2MSFTNGP10.phx.gbl...
> OK, that works. However when IE opens it is minimized to the startbar.

Is
> there a way to have it open as the active window?
>
> Now, I have this code behind a button
> ----------------------------------------------------------------
> Dim URLAddress As String
>
> GL_Address =
>

Forms![frmRecruitment]![frmAppointment].Form![frmAppointmentLocation].Form![
> Address]
> GL_City =
>

Forms![frmRecruitment]![frmAppointment].Form![frmAppointmentLocation].Form![
> City]
> GL_State = Me![frmAppointmentLocation].Form![StateID]
> GL_Zip = Me![frmAppointmentLocation].Form![Zip]
>
> MapAddress = ChangeStr(GL_Address, Chr$(32), Chr$(43), 0)
> MapCity = ChangeStr(GL_City, Chr$(32), Chr$(43), 0)
>
> URLAddress =
> "http://www.mapquest.com/maps/map.adp?country=US&addtohistory=&address=" +
> MapAddress + "state=" + GL_State + "&zipcode=" + GL_Zip +
> "&homesubmit=Get+Map"
>
> Shell "C:\Program Files\Internet Explorer\iexplore.exe " & URLAddress
> --------------------------------------------------------------------------
>
> This opens IE to mapquest and finds an address
>
>
>
>
>
>
> <SteveT> wrote in message news:eb5MbgqWDHA.2360@TK2MSFTNGP12.phx.gbl...
> > Occurs to me I may have missed your question. I was thinking of the

> browser
> > object inserted on a form...
> >
> > In code this works to start IE and go to 'www.msn.com':
> >
> > Shell "C:\Program Files\Internet Explorer\iexplore.exe www.msn.com"
> >
> > Steve
> >
> > <SteveT> wrote in message

news:%23JC8daqWDHA.1680@tk2msftngp13.phx.gbl...
> > > Lisa,
> > >
> > > Using the Microsoft Web Browser object, in the click event of a

button,
> > the
> > > following works:
> > >
> > >
> > > Dim ctl As Object
> > > Dim var As Long
> > >
> > > Set ctl = Me.ctlWebBrowser.Object
> > >
> > > ctl.Navigate ("www.google.com")
> > >
> > >
> > > While you're at it, you can test for and use the Updated event and run

> > code
> > > if required:
> > >
> > > Private Sub ctlWebBrowser_Updated(Code As Integer)
> > > Me.Command1.Visible = True
> > > Me.Command1.SetFocus
> > > End Sub
> > >
> > > Use the Object Browser to inspect all the events and properties.
> > >
> > > Steve
> > >
> > >
> > >
> > > "Lisa B." <lbagley@MayaTech.com> wrote in message
> > > news:%23U2iIRqWDHA.2476@tk2msftngp13.phx.gbl...
> > > > Does anyone know the code to open the web browser and go to a URL

> listed
> > > in
> > > > a field.
> > > >
> > > > I know I can do it if I make the field a hyperlink, but the field is

> on
> > a
> > > > sub form and will be invisible to the user.
> > > >
> > > >
> > >
> > >

> >
> >

>
>



  Reply With Quote
Old 04-08-2003, 10:04 PM   #8
Lisa B.
Guest
 
Posts: n/a
Default Re: Open Web browser with code

This works, Thank You.

<SteveT> wrote in message news:uQzr6AsWDHA.1640@TK2MSFTNGP10.phx.gbl...
>
> Try:
>
> Shell "C:\Program Files\Internet Explorer\iexplore.exe " & URLAddress
> ,vbMaximizedFocus
>
>
>
> "Lisa B." <lbagley@MayaTech.com> wrote in message
> news:%231mpJDrWDHA.1736@TK2MSFTNGP10.phx.gbl...
> > OK, that works. However when IE opens it is minimized to the startbar.

> Is
> > there a way to have it open as the active window?
> >
> > Now, I have this code behind a button
> > ----------------------------------------------------------------
> > Dim URLAddress As String
> >
> > GL_Address =
> >

>

Forms![frmRecruitment]![frmAppointment].Form![frmAppointmentLocation].Form![
> > Address]
> > GL_City =
> >

>

Forms![frmRecruitment]![frmAppointment].Form![frmAppointmentLocation].Form![
> > City]
> > GL_State = Me![frmAppointmentLocation].Form![StateID]
> > GL_Zip = Me![frmAppointmentLocation].Form![Zip]
> >
> > MapAddress = ChangeStr(GL_Address, Chr$(32), Chr$(43), 0)
> > MapCity = ChangeStr(GL_City, Chr$(32), Chr$(43), 0)
> >
> > URLAddress =
> > "http://www.mapquest.com/maps/map.adp?country=US&addtohistory=&address="

+
> > MapAddress + "state=" + GL_State + "&zipcode=" + GL_Zip +
> > "&homesubmit=Get+Map"
> >
> > Shell "C:\Program Files\Internet Explorer\iexplore.exe " & URLAddress

>
> --------------------------------------------------------------------------
> >
> > This opens IE to mapquest and finds an address
> >
> >
> >
> >
> >
> >
> > <SteveT> wrote in message news:eb5MbgqWDHA.2360@TK2MSFTNGP12.phx.gbl...
> > > Occurs to me I may have missed your question. I was thinking of the

> > browser
> > > object inserted on a form...
> > >
> > > In code this works to start IE and go to 'www.msn.com':
> > >
> > > Shell "C:\Program Files\Internet Explorer\iexplore.exe www.msn.com"
> > >
> > > Steve
> > >
> > > <SteveT> wrote in message

> news:%23JC8daqWDHA.1680@tk2msftngp13.phx.gbl...
> > > > Lisa,
> > > >
> > > > Using the Microsoft Web Browser object, in the click event of a

> button,
> > > the
> > > > following works:
> > > >
> > > >
> > > > Dim ctl As Object
> > > > Dim var As Long
> > > >
> > > > Set ctl = Me.ctlWebBrowser.Object
> > > >
> > > > ctl.Navigate ("www.google.com")
> > > >
> > > >
> > > > While you're at it, you can test for and use the Updated event and

run
> > > code
> > > > if required:
> > > >
> > > > Private Sub ctlWebBrowser_Updated(Code As Integer)
> > > > Me.Command1.Visible = True
> > > > Me.Command1.SetFocus
> > > > End Sub
> > > >
> > > > Use the Object Browser to inspect all the events and properties.
> > > >
> > > > Steve
> > > >
> > > >
> > > >
> > > > "Lisa B." <lbagley@MayaTech.com> wrote in message
> > > > news:%23U2iIRqWDHA.2476@tk2msftngp13.phx.gbl...
> > > > > Does anyone know the code to open the web browser and go to a URL

> > listed
> > > > in
> > > > > a field.
> > > > >
> > > > > I know I can do it if I make the field a hyperlink, but the field

is
> > on
> > > a
> > > > > sub form and will be invisible to the user.
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >

> >
> >

>
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off