none
How To Call The Help API From VBA? RRS feed

  • Question

  • Trying to debug this so I stripped the code down to:

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

    Public Function LaunchHelp(ByVal lHelpID)

        Const HH_HELP_CONTEXT = &HF            

        Dim hwndHelp As Long
                           
        hwndHelp = HtmlHelp(GetDesktopWindow(), "C:\Windows\Help\mui\0409\cmak_ops.CHM", HH_HELP_CONTEXT, lHelpID)

        Stop           
     
    End Function

    Using a Windows supplied help file to test. 

    Calling it:

    LaunchHelp 0

    Should just open the help file but nothing happens and hwndHelp contains 0. Both err.LastDLLError and Err.number are zero.

    What am I missing?


    http://www.saberman.com

    Tuesday, October 6, 2015 11:13 PM

Answers

  • This how I call a custom Help file (ORCAS.chm) that's in my current path:

    Public Const HH_DISPLAY_TOPIC = &H0
    Public Const HH_SET_WIN_TYPE = &H4
    Public Const HH_GET_WIN_TYPE = &H5
    Public Const HH_GET_WIN_HANDLE = &H6
    Public Const HH_DISPLAY_TEXT_POPUP = &HE
    Public Const HH_HELP_CONTEXT = &HF
    Public Const HH_TP_HELP_CONTEXT = &H10
    Public Const HH_TP_HELP_CONTEXTMENU = &H10
    Public Const HH_TP_HELP_WM_HELP = &H11
    Public Const WM_CLOSE = &H10

    Public 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

    Public Function ORCASHelp() As Boolean
    ChDir CurrentProject.Path
    Dim hwndHelp As Long
    hwndHelp = HtmlHelp(0, "ORCAS.chm", HH_HELP_CONTEXTMENU, 0)

    Maybe you can adapt it to your needs.

    Wednesday, October 7, 2015 5:36 PM