Open Web browser to a specific Page

 

 

This code will allow you to open a web browser to a specific web page using VB.
Add a command button to your project and cut and paste the code below.


Private 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


Private Sub cmdOpentoSite_Click()
Dim webpage
webpage = ShellExecute(Me.hwnd, "Open", "http://thewebsite.com", "", App.Path, 1)
End Sub

You can actually use exactly the same method to open your default email client; simply substitite the http URL with a "mailto:email@site.com" in the example above.