Calling an application Help file from VBA???

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

Guest

I'm sure that there is but I can't find the method to call an application
help file w/
context id.

I have created a .hlp file and it works in a form using the f1 key but how
do you call it programatically from VBA. I do not want to use a message
box. I either want to call help or have the context as a pop up.

Does this make sense? I'd be happy to clarify
 
You didn't specify what type of help file, but these functions should
help...

Option Explicit

'These are used for HTMLHelp

Private Const HH_DISPLAY_TOPIC = &H0
Private Const HH_SET_WIN_TYPE = &H4
Private Const HH_GET_WIN_TYPE = &H5
Private Const HH_GET_WIN_HANDLE = &H6
Private Const HH_DISPLAY_TEXT_POPUP = &HE ' Display string resource ID or
' text in a pop-up window.
Private Const HH_HELP_CONTEXT = &HF ' Display mapped numeric value
in
' dwData.
Private Const HH_TP_HELP_CONTEXTMENU = &H10 ' Text pop-up help, similar to
' WinHelp's HELP_CONTEXTMENU.
Private Const HH_TP_HELP_WM_HELP = &H11 ' text pop-up help, similar to
' WinHelp's HELP_WM_HELP.


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


'These are used for WinHelp
Private Const HELP_CONTEXT = &H1 'Display topic for Help context ID.
Private Const HELP_QUIT = &H2 'Terminate Help.
Private Const HELP_INDEX = &H3 'Display Help index.
Private Const HELP_CONTEXTPOPUP = &H8& 'Display Help context as a pop-up
'window.
Private Const HELP_FINDER = &HB& 'If found, Display container file.
Private Const HELP_KEY = &H101 'Display topic for keyword.

'Declare the WinHelp function.
Private Declare Sub WinHelp Lib "user32" Alias "WinHelpA" (ByVal hWnd As
Long, _
ByVal lpHelpFile As String, ByVal wCommand As Long, _
ByVal dwData As Any)

Function OpenWinHelpContainer(hWnd As Long, ByVal FileName As String)
'Opens the Help container.
WinHelp hWnd, ByVal FileName, _
HELP_FINDER, ByVal vbNullString
End Function

Function OpenWinHelpIndex(hWnd As Long, ByVal FileName As String)
'Opens the Help index.
WinHelp hWnd, ByVal FileName, HELP_KEY, _
ByVal ""
End Function

Function OpenWinHelpIndexToSearchKey(hWnd As Long, ByVal FileName As String,
_
ByVal SearchKey As String)
'Opens the Help index and searches for keyword SKey.
WinHelp hWnd, ByVal FileName, HELP_KEY, _
ByVal SearchKey
End Function

Function OpenWinHelpToContextID(hWnd As Long, ByVal FileName As String, _
ContextID As Long)
'Opens the Help file to ContextID.
WinHelp hWnd, ByVal FileName, _
HELP_CONTEXT, ByVal ContextID
End Function

Function OpenWinHelpToContextIDPopup(hWnd As Long, ByVal FileName As String,
_
ContextID As Long)
'Opens the Help file to ContextID as a pop-up window.
WinHelp hWnd, ByVal FileName, _
HELP_CONTEXTPOPUP, ByVal ContextID
End Function

Function CloseWinHelpContainer(hWnd As Long, ByVal FileName As String)
'Closes the specified Help file.
WinHelp hWnd, ByVal FileName, HELP_QUIT, _
ByVal vbNullString
End Function

Function OpenHTMLHelp(hWnd As Long, FileName As String)
Dim lngResult As Long
'Opens HTML help file
lngResult = HtmlHelp(hWnd, FileName, HH_DISPLAY_TOPIC, 0)

End Function

Function OpenHTMLHelpToContextID(hWnd As Long, FileName As String, ContextID
As Long)
Dim lngResult As Long
'Opens HTML Help file to ContextID
lngResult = HtmlHelp(hWnd, FileName, HH_HELP_CONTEXT, ContextID)

End Function
 
Thanks so much for the help. No pun intended

Paul Overway said:
You didn't specify what type of help file, but these functions should
help...

Option Explicit

'These are used for HTMLHelp

Private Const HH_DISPLAY_TOPIC = &H0
Private Const HH_SET_WIN_TYPE = &H4
Private Const HH_GET_WIN_TYPE = &H5
Private Const HH_GET_WIN_HANDLE = &H6
Private Const HH_DISPLAY_TEXT_POPUP = &HE ' Display string resource ID or
' text in a pop-up window.
Private Const HH_HELP_CONTEXT = &HF ' Display mapped numeric value
in
' dwData.
Private Const HH_TP_HELP_CONTEXTMENU = &H10 ' Text pop-up help, similar to
' WinHelp's HELP_CONTEXTMENU.
Private Const HH_TP_HELP_WM_HELP = &H11 ' text pop-up help, similar to
' WinHelp's HELP_WM_HELP.


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


'These are used for WinHelp
Private Const HELP_CONTEXT = &H1 'Display topic for Help context ID.
Private Const HELP_QUIT = &H2 'Terminate Help.
Private Const HELP_INDEX = &H3 'Display Help index.
Private Const HELP_CONTEXTPOPUP = &H8& 'Display Help context as a pop-up
'window.
Private Const HELP_FINDER = &HB& 'If found, Display container file.
Private Const HELP_KEY = &H101 'Display topic for keyword.

'Declare the WinHelp function.
Private Declare Sub WinHelp Lib "user32" Alias "WinHelpA" (ByVal hWnd As
Long, _
ByVal lpHelpFile As String, ByVal wCommand As Long, _
ByVal dwData As Any)

Function OpenWinHelpContainer(hWnd As Long, ByVal FileName As String)
'Opens the Help container.
WinHelp hWnd, ByVal FileName, _
HELP_FINDER, ByVal vbNullString
End Function

Function OpenWinHelpIndex(hWnd As Long, ByVal FileName As String)
'Opens the Help index.
WinHelp hWnd, ByVal FileName, HELP_KEY, _
ByVal ""
End Function

Function OpenWinHelpIndexToSearchKey(hWnd As Long, ByVal FileName As String,
_
ByVal SearchKey As String)
'Opens the Help index and searches for keyword SKey.
WinHelp hWnd, ByVal FileName, HELP_KEY, _
ByVal SearchKey
End Function

Function OpenWinHelpToContextID(hWnd As Long, ByVal FileName As String, _
ContextID As Long)
'Opens the Help file to ContextID.
WinHelp hWnd, ByVal FileName, _
HELP_CONTEXT, ByVal ContextID
End Function

Function OpenWinHelpToContextIDPopup(hWnd As Long, ByVal FileName As String,
_
ContextID As Long)
'Opens the Help file to ContextID as a pop-up window.
WinHelp hWnd, ByVal FileName, _
HELP_CONTEXTPOPUP, ByVal ContextID
End Function

Function CloseWinHelpContainer(hWnd As Long, ByVal FileName As String)
'Closes the specified Help file.
WinHelp hWnd, ByVal FileName, HELP_QUIT, _
ByVal vbNullString
End Function

Function OpenHTMLHelp(hWnd As Long, FileName As String)
Dim lngResult As Long
'Opens HTML help file
lngResult = HtmlHelp(hWnd, FileName, HH_DISPLAY_TOPIC, 0)

End Function

Function OpenHTMLHelpToContextID(hWnd As Long, FileName As String, ContextID
As Long)
Dim lngResult As Long
'Opens HTML Help file to ContextID
lngResult = HtmlHelp(hWnd, FileName, HH_HELP_CONTEXT, ContextID)

End Function
 
Back
Top