此 VBA 代码在 32 位 Microsoft Office 和 VBA6 的 CHM 中显示上下文相关帮助:
Private Declare Function HtmlHelp Lib "HHCtrl.ocx" Alias "HtmlHelpA" _
(ByVal hWndCaller As Long, _
ByVal pszFile As String, _
ByVal uCommand As Long, _
dwData As Any) As Long
Const HH_DISPLAY_TOPIC As Long = 0
HtmlHelp hwnd, sPathToCHM, HH_DISPLAY_TOPIC, ByVal "topic_name.htm"
此代码在使用 VBA7 的 64 位 Microsoft Office 中不显示任何错误消息:
Declare PtrSafe Function HtmlHelp Lib "hhctrl.ocx" Alias "HtmlHelpA" _
(ByVal hwndCaller As LongPtr, _
ByVal pszFile As String, _
ByVal uCommand As Long, _
ByVal dwData As String) As Long
HtmlHelp(hwndCalling, strHelpTopicFile, HH_DISPLAY_TOPIC, strHelpTopic)