Solved

Opening Browser

Posted on 2002-06-09
8
168 Views
Last Modified: 2010-05-02
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.
0
Comment
Question by:alak
8 Comments
 
LVL 2

Expert Comment

by:priya_pbk
ID: 7066288
yes you can open an htm page in an IE thru VB application. Here it is :

'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


0
 

Expert Comment

by:HeN_da_MaN
ID: 7066347
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
0
 
LVL 6

Expert Comment

by:Nitin Sontakke
ID: 7066405
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.
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 6

Accepted Solution

by:
Nitin Sontakke earned 100 total points
ID: 7066409
Here is the tested code...

Private Sub Command1_Click()
    Call Shell("Cmd /cStart " & htmlFileName)
End Sub
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 7066558
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
0
 

Author Comment

by:alak
ID: 7068993
Thank you very much for helping. It is working fine.
0
 
LVL 6

Expert Comment

by:Nitin Sontakke
ID: 7069348
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.
0
 
LVL 6

Expert Comment

by:Nitin Sontakke
ID: 7069354
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

0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Windows 10 start screen issues 9 55
how to know if my Checkbox is True in VB6.0? 9 55
Excel Automation VBA 19 70
Error with a code discussed on this page 5 14
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question