vrijdag 26 september 2008

Open default browser

This source code will open a site/html page in the clients default browser (for example Internet Explorer or Firefox).


Add the following source code to a module:

'***************************************************************

'Windows APIl Declarations for :Open Default Web Browser '***************************************************************

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


Public Sub GotoWebsite(window As Variant, url As String)
'Opens the default webbrowser with url url,
'window is a reference to a form/window
Dim ret&
ret& = ShellExecute(window.hwnd, "Open", url, "", App.Path, 1)
End Sub

If you want to open a browser window from a form, use the following VB code:

GotoWebsite(Me, "http://www.compuonline.info/")