Solved

Open the favorite webbrowser from VB

Posted on 1999-01-08
4
154 Views
Last Modified: 2010-05-03
This is probably a common question. I want to be able to open HTML-documents in the user's webbrowser. To make it a little harder for you, experts, I want to make sure that a 4.0 browser from Netscape or Microsoft is used. How can I achieve this?
0
Comment
Question by:liljegren
  • 2
4 Comments
 

Author Comment

by:liljegren
ID: 1454907
Edited text of question
0
 
LVL 1

Expert Comment

by:bear454
ID: 1454908
And what do you do if the user does not have a 4.x browser installed?
0
 
LVL 13

Accepted Solution

by:
Mirkwood earned 50 total points
ID: 1454909
Here is how to execute a html file.
To verify whether or not version4 is installed is a completly other question.

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 Declare Function GetDesktopWindow Lib "user32" () As Long
Private Const SW_SHOWNORMAL = 1
  

     'Description:How do I launch a file in its associated program?

Function StartDoc(DocName As String) As Long

       Dim Scr_hDC As Long
       Scr_hDC = GetDesktopWindow()
       StartDoc = ShellExecute(Scr_hDC, "Open", DocName, "", "C:\", SW_SHOWNORMAL)
End Function
  
Private Sub Form_Click()
       Dim r As Long
       r = StartDoc("c:\myhtml.html")
       Debug.Print "Return code from Startdoc: "; r
End Sub

0
 

Author Comment

by:liljegren
ID: 1454910
That was a piece of useful code. Guess I have to make another question on the 4.0 issue. The program generate HTML documents. If the user doesn't have a 4.0 browser, the program should generate a HTML 3.2 document with <FONT> tags, instead of the HTML 4.0 + CSS document.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

840 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