Module: HelpHTML in Category Windows : Help Files from Total Visual SourceBook

Working with Windows HTML Help files (usually named *.CHM or *.HTML) in VB6 and VBA with 32 and 64-bit Windows API calls.

Microsoft Access forms have a HelpFile property that supports legacy *.HLP format files, but not the newer *.CHM help file format.

Procedure Name Type Description
(Declarations) Declarations Declarations and private variables for the modHelpHTML module.
Help_HTML Procedure Open an HTML/CHM help file for a particular ID.
Help_HTML_Index Procedure Open an HTML/CHM help file on the Index tab.
Help_HTML_Contents Procedure Open an HTML/CHM help file on the first item displaying the treeview list of contents.
Help_HTML_Search Procedure Open an HTML/CHM help file on the search tab. Due to a Microsoft bug, it's not possible to execute a search string.
Help_HTML_Topic Procedure Call the Windows help API to launch an application's help file in CHM format for a particular topic name.
Help_HTML_CloseAll Procedure Close all help files opened by this application.
' Example of modHelpHTML
' To use this example:
' 1. Create a new form
' 2. Create the following command buttons:
'       'cmdOpen'
'       'cmdClose'
' 3. Create a combo box named 'cboOpenTo'
' 4. Create the following text boxes:
'       'txtFile'
'       'txtContextID'
'       'txtTopic'
' 4. Paste the entire contents of this module into the new form's module.

Private Sub cmdClose_Click()
End Sub

Private Sub cmdOpen_Click()
  ' Constant to control whether the help file is maximized when opened.
  Const cfMax As Boolean = False

  Select Case Me.cboOpenTo
    Case "ContextID"
      Help_HTML Me.txtFile, Me.txtContextID, cfMax
    Case "Contents"
      Help_HTML_Contents Me.txtFile, cfMax
    Case "Index"
      Help_HTML_Index Me.txtFile, cfMax
    Case "Search"
      Help_HTML_Search Me.txtFile, cfMax
    Case "Topic"
      Help_HTML_Topic Me.txtFile, Me.txtTopic, cfMax
  End Select
End Sub

Private Sub Form_Load()
  ' Constants to use as defaults
  Const cstrHelpFile As String = "TVSB.chm"
  Const cstrTopic As String = "Example_Code"
  Const clngID As Long = 32

  ' Provide full path to help file. Uses Access command for the current database's path.
  Me.txtFile = CurrentProject.Path & "\" & cstrHelpFile

  Me.txtContextID.Format = "#"
  Me.txtContextID = clngID
  Me.txtTopic = cstrTopic

  ' Captions on buttons
  Me.cmdClose.Caption = "Close All"
  Me.cmdOpen.Caption = "Open Help"

  With cboOpenTo
    .RowSourceType = "Value List"
    .RowSource = "ContextID;Contents;Index;Search;Topic"
    .LimitToList = True
    .Value = "ContextID"
  End With
End Sub

Total Visual SourceBook The source code in Total Visual Sourcebook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.

Total Visual SourceBook is written for the needs of a developer using a source code library covering the many challenges you face. Countless developers over the years have told us they learned some or much of their development skills and tricks from our code. You can too!

Additional Resources

Total Visual SourceBook CD and Printed Manual

Microsoft Access/ Office 2016, 2013, 2010, and 2007 Version
is Shipping!

New features in Total Visual SourceBook for Access, Office and VB6

Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!

View all FMS products for Microsoft Access All Our Microsoft Access Products


Reader Choice Award for MS Access Source Code Library
Reader Choice

"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."

Van T. Dinh, Microsoft MVP

SourceBook Info

Additional Info




Free Product Catalog from FMS