-
Dear All,
I would like to ask you guys about linking my VB application with Internet Explorer.
Suppose, I make a menu (from menu editor) with "Report" as its caption.
If user click "Report" menu, my VB application will open Internet Explorer browser with a spesific address.
Lets say the address is "http://development/"
How should I do that.... ?
I know this is a simple question...
But, thx anyway...
nd need it ASAP
Cheers,
Wen Lie
-
<?>
Code:
'open a browser and go to a www address
'bas module
'
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
Function ShellToBrowser%(Frm As Form, ByVal URL$, ByVal WindowStyle%)
Dim api%
api% = ShellExecute(Frm.hwnd, "open", URL$, "", App.Path, WindowStyle%)
'Check return value
If api% < 31 Then
'error code - see api help for more info
Dim msg As String
msg = "This item doesn't work with your system"
MsgBox msg, vbCritical, "Error"
ShellToBrowser% = False
ElseIf api% = 32 Then
'no file association
Dim msg1 As String
msg1 = "This item doesn't work with your system"
MsgBox msg, vbCritical, "Error"
ShellToBrowser% = False
Else
'It worked!
ShellToBrowser% = True
End If
End Function
'
'<<< event from application...click event of button >>>>>>>>
'
Private Sub cmdWeb_Click()
Dim Site As String
Dim success As Integer
Site = "http://www.Yahoo.com/" '& Trim(txtWeb.Text)
success% = ShellToBrowser(Me, Site, 0)
End Sub