VB6: Browser Based Help from a button on your form

Download
You can import the required module mOpenHyperLink from the Access demo application which you can download from here: msaccess_activating_help.zip

Calling the opening of a html page on a browser is easy. In it's most primitive form you only need to call the OpenHyperLink procedure as in the downloaded application module mOpenHyperLink. This in turn will call the windows API Function ShellExecute  Lib "shell32.dll" , that's all. The code below is optional. It has the advantage that you don't have to include the full path to your topic page each time. In addition it shows how to specify the url in case of file server versus web server, and gives the correct direction of the slash as part of the path.

  1. Import module mOpenHyperLink from the downloaded application.
  2. By default the help opens from the file server. If you want to open from the Internet, change the line
    Sub  MyOpenHyperlink strTopicPage  As String , Optional bOnTheInternet  As Boolean )
    to
    Sub  MyOpenHyperlink(strTopicPage  As   String , Optional bOnTheInternet  As Boolean = True )
  3. In addition, you will need to specify the folder on the web server you will be using. Replace the http://... part. 
     If bOnTheInternet  Then strHTMLfilesFolder = "http://helpgenerator.com/help/vb6"
  4. Open the form you want to add the help button to in View Object
  5. Add a [Help] button to a form
  6. Set the button property name to 'cmdHelp'
  7. Open the form via View Code
  8. In the left combo box select the button control 'cmdHelp'
    Private Sub 'cmdHelp_Click() ... End Sub is inserted
  9. Insert code so that the result looks like below one of below:

Private Sub cmdHelp_Click()
    MyOpenHyperlink "help.htm"
End Sub

Note

Other ways to call MyOpenHyperlink:

  • MyOpenHyperlink "Add_code_to_activate_help.htm"
    opens that topic page. If the appropriate javascript code (from quick part JsOpenInFrame) is included, it will automatically open the frame page help.htm so that navigation features are made available.
  • MyOpenHyperlink "help.htm?Add_code_to_activate_help.htm"

Private Sub  cmdHelpInternet_Click()
    MyOpenHyperlink "help.htm?frmBrowserBasedHelp.htm",  True
End Sub

Note
The http address is specified in MyOpenHyperlink
VB6: starting help from code