• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 162
  • Last Modified:

Open the favorite webbrowser from VB

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
liljegren
Asked:
liljegren
  • 2
1 Solution
 
liljegrenAuthor Commented:
Edited text of question
0
 
bear454Commented:
And what do you do if the user does not have a 4.x browser installed?
0
 
MirkwoodCommented:
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
 
liljegrenAuthor Commented:
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

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now