Open Web Browser from VBA 
Author Message
 Open Web Browser from VBA

Please help!  I'm trying to open a client's default web
browser to a specific site and I cannot figure out the
line of code.  Any ideas?


Sat, 30 Apr 2005 04:37:52 GMT  
 Open Web Browser from VBA
Hi,

The only way that I know is to use the ShellExecute API.

For example,

Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA"
(ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String,
ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As
Long) As Long

Dim ReturnValue As Long

Private Sub Command1_Click()
Dim ReturnValue As Long
    ReturnValue = ShellExecute(Me.hwnd, "", "www.microsoft.com", "", "", 0&)
End Sub

(simplest form).  Use a string variable to specify the URL, unless a literal
is sufficient.

--
Richard Grier  (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 3rd
Edition ISBN 1-890422-27-4 (391 pages) published February 2002.



Sat, 30 Apr 2005 08:19:04 GMT  
 Open Web Browser from VBA
Thank you so much for your assistance!  I got the code to
work when I used a string variable to specify the URL.  
Thanks again!  You saved me a lot of trial-and-error!  Nate

Quote:
>-----Original Message-----
>Hi,

>The only way that I know is to use the ShellExecute API.

>For example,

>Public Declare Function ShellExecute Lib "shell32.dll"

Alias "ShellExecuteA"
Quote:
>(ByVal hwnd As Long, ByVal lpOperation As String, ByVal
lpFile As String,
>ByVal lpParameters As String, ByVal lpDirectory As

String, ByVal nShowCmd As
Quote:
>Long) As Long

>Dim ReturnValue As Long

>Private Sub Command1_Click()
>Dim ReturnValue As Long
>    ReturnValue = ShellExecute

(Me.hwnd, "", "www.microsoft.com", "", "", 0&)
Quote:
>End Sub

>(simplest form).  Use a string variable to specify the

URL, unless a literal
Quote:
>is sufficient.

>--
>Richard Grier  (Microsoft Visual Basic MVP)

>See www.hardandsoftware.net for contact information.

>Author of Visual Basic Programmer's Guide to Serial
Communications, 3rd
>Edition ISBN 1-890422-27-4 (391 pages) published February
2002.

>.



Mon, 09 May 2005 02:13:54 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Web Browser: Opening link in new Web Browser window

2. How can I open a web browser with an open document

3. How to make my web browser as a default web browser

4. Using VBA to change the Text Size in Outlook's web browser

5. Opening several web-browser instancies at the same time

6. opening the default web browser in VB

7. Opening Default Web Browser or E-Mail Application

8. Open *.html location in web browser

9. Help - how to open a web browser from vb5

10. How to open ASP pages in web browser?

11. Opening Web browser

12. Web browser open dialog -OLECMDID_OPEN

 

 
Powered by phpBB® Forum Software