How to load a help file using VBA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I created a HTML Help file (with .CHM extension). I want to load it by running a macro in Excel. Can anyone teach me how? Thanks.
 
An example:

Const HH_DISPLAY_TOPIC = &H0

Declare Function HtmlHelp Lib "hhctrl.ocx" Alias "HtmlHelpA" _
(ByVal hwndCaller As Long, ByVal pszFile As String, _
ByVal uCommand As Long, ByVal dwData As Long) As Long

Sub DisplayHTMLHelp()
Dim hwndHelp As Long
hwndHelp = HtmlHelp(0, "C:\MSO2K\Office\1033\xlmain9.chm", _
HH_DISPLAY_TOPIC, 0)
End Sub
 
An example:

Const HH_DISPLAY_TOPIC = &H0

Declare Function HtmlHelp Lib "hhctrl.ocx" Alias "HtmlHelpA" _
(ByVal hwndCaller As Long, ByVal pszFile As String, _
ByVal uCommand As Long, ByVal dwData As Long) As Long

Sub DisplayHTMLHelp()
Dim hwndHelp As Long
hwndHelp = HtmlHelp(0, "C:\MSO2K\Office\1033\xlmain9.chm", _
HH_DISPLAY_TOPIC, 0)
End Sub

Or simpler:
Shell ("CMD /c Start d:\path\MyHelp.chm")
To replace CMD with the content of the environment variable COMSPEC is
left as an exercise for the reader.

Or in NT-class OSs:
Shell ("RunDLL32.exe Shell32.DLL,ShellExec_RunDLL" _
& " d:\path\MyHelp.CHM")
[The clumsy literal construct is only here to avoid line wrapping by
news readers.]
 
Back
Top