alak
asked on
Opening Browser
Can I able to open a html page in internet explorer on click on a button in vb application? I am able to open the page with web browser control which is opening the in that vb application in a form there is no addressbar, menubar, statusbar etc. But I want to open the page in internet explorer 6.0. I have installed vb6.0.
Set a reference to "Microsoft Internet Controls"
Private Sub Command1_Click()
Dim objBrowser As InternetExplorer
Set objBrowser = New InternetExplorer
objBrowser.Navigate2 "http://www.whatever.com"
objBrowser.Visible = True
End Sub
Where the declaration could be global or like this in the function
cheers
hen
Private Sub Command1_Click()
Dim objBrowser As InternetExplorer
Set objBrowser = New InternetExplorer
objBrowser.Navigate2 "http://www.whatever.com"
objBrowser.Visible = True
End Sub
Where the declaration could be global or like this in the function
cheers
hen
I don't know how reliable it is, but you can also give following shell command:
Call Shell("Start " & htmlFileName)
If filename has .htm or .html extension, Start will workout which program to invoke and will show page in IE, provided, of course, it is a default browser.
Call Shell("Start " & htmlFileName)
If filename has .htm or .html extension, Start will workout which program to invoke and will show page in IE, provided, of course, it is a default browser.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hello
Using the ShellExecute API is the better way I use for that, it's only need the path
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 Command1_Click()
Dim I As Long
I = ShellExecute(0, "Open", "www.google.com", "", "", 1)
End Sub
Using the ShellExecute API is the better way I use for that, it's only need the path
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 Command1_Click()
Dim I As Long
I = ShellExecute(0, "Open", "www.google.com", "", "", 1)
End Sub
ASKER
Thank you very much for helping. It is working fine.
Thanks.
But, let me be honest here.
As stated earlier, i am not sure how reliable it is. The reason to say this is given below. However, it all depends on you target platforms. If they are all same, it really doesn't matter. However, if not, then....
I am not too sure, but some environments have "Command" command to invoke the command interpreter and some have "Cmd". As i guess it, the NT based OS such as NT, XP, Win2K Advanced Server have "CMD", and Win9x have "Command" command.
If you are attempting to target Win9x OS, i will suggest that you test your app on these OS before any commercial deployment.
With this revelations, i wouldn't mind if take back my point and reopen the question, if you want.
Thanks again.
But, let me be honest here.
As stated earlier, i am not sure how reliable it is. The reason to say this is given below. However, it all depends on you target platforms. If they are all same, it really doesn't matter. However, if not, then....
I am not too sure, but some environments have "Command" command to invoke the command interpreter and some have "Cmd". As i guess it, the NT based OS such as NT, XP, Win2K Advanced Server have "CMD", and Win9x have "Command" command.
If you are attempting to target Win9x OS, i will suggest that you test your app on these OS before any commercial deployment.
With this revelations, i wouldn't mind if take back my point and reopen the question, if you want.
Thanks again.
In line with what is said above, the following might help.
Private Sub Command1_Click()
If Environ("OS") = "Windows_NT" Then
Call Shell("Cmd /cStart " & htmlFileName)
Else
Call Shell("Command /cStart " & htmlFileName)
End If
End Sub
Private Sub Command1_Click()
If Environ("OS") = "Windows_NT" Then
Call Shell("Cmd /cStart " & htmlFileName)
Else
Call Shell("Command /cStart " & htmlFileName)
End If
End Sub
'declare at the start of the module
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
Sub command1_click()
'whatever page ie from the net or from local drive,
'just write the path of the htm file
Call Shell("C:/Program Files/Plus!/Microsoft Internet/iexplore.exe http://1.1.1.1/project/htmpreview.htm", vbMaximizedFocus)
End Sub
Write the path of the iexplorer whereever it exists.I hope this helps
-priya