Article ID: 188320
Article Last Modified on 1/23/2007
Shell "winhlp32.exe c:\win95\system\msadtctl.hlp"
With ActiveXCtl0 'Refers to the common dialog control .HelpFile = "c:\windows\system\calc.hlp" .HelpCommand = 15 .ShowHelp End With
Option Compare Database
Option Explicit
Public Const HELP_CONTEXT = &H1 ' Display topic by Help
' context ID.
Public Const HELP_QUIT = &H2 ' Terminate Help.
Public Const HELP_INDEX = &H3 ' Display Help index.
Public Const HELP_CONTEXTPOPUP = &H8& ' Display Help context as a
' pop-up window.
Public Const HELP_FINDER = &HB& ' If found, Display
' container file.
Public Const HELP_KEY = &H101 ' Display topic for
' keyword.
' Declare the WinHelp function.
Declare Sub WinHelp Lib "user32" Alias _
"WinHelpA" (ByVal Hwnd As Long, ByVal lpHelpFile As String, _
ByVal wCommand As Long, ByVal dwData As Any)
Function OpenHelpContainer(ByVal strHelpFileName As String)
' Opens the Help container.
WinHelp Application.hWndAccessApp, _
ByVal strHelpFileName, HELP_FINDER, ByVal vbNullString
End Function
Function OpenHelpIndex(ByVal strHelpFileName As String)
' Opens the Help index.
WinHelp Application.hWndAccessApp, ByVal strHelpFileName, _
HELP_KEY, ByVal ""
End Function
Function OpenHelpIndexWithSearchKey(ByVal strHelpFileName _
As String, ByVal strSearchKey As String)
' Opens the Help index and searches for keyword SKey.
WinHelp Application.hWndAccessApp, ByVal _
strHelpFileName, HELP_KEY, ByVal strSearchKey
End Function
Function OpenHelpWithContextID(ByVal strHelpFileName As _
String, lngContextID As Long)
' Opens the Help file to ContextID.
WinHelp Application.hWndAccessApp, ByVal strHelpFileName, _
HELP_CONTEXT, ByVal lngContextID
End Function
Function OpenHelpWithContextIDPopup(ByVal strHelpFileName As String, _
lngContextID As Long)
' Opens the Help file to ContextID as a pop-up window.
WinHelp Application.hWndAccessApp, ByVal strHelpFileName, _
HELP_CONTEXTPOPUP, ByVal lngContextID
End Function
Function CloseHelpContainer(ByVal strHelpFileName As String)
' Closes the specified Help file.
WinHelp Application.hWndAccessApp, _
ByVal strHelpFileName, HELP_QUIT, ByVal vbNullString
End Function
The above code provides some useful functions for displaying Help files.
The list below describes the purpose of each.
?OpenHelpContainer("Calc.hlp")
This opens the Help file for the Microsoft Windows Calculator.
?OpenHelpIndex("Calc.hlp")
This opens the Help file for the Microsoft Windows Calculator with the
Index tab displayed.
?OpenHelpIndexWithSearchKey("calc.hlp","simple calculations")
Note that the "Simple Calculations" topic ID is displayed.
?OpenHelpWithContextID("calc.hlp",90)
Note that it opens Help for the division button.
?OpenHelpWithContextIDPopup("Calc.hlp",90)
Note that it opens Help for the division button in a pop-up window.
?CloseHelpContainer("Calc.hlp")
This should close the Microsoft Windows Calculator Help file if it is
open.163435 VBA: Programming Resources for Visual Basic for Applications
Keywords: kbhowto kbprogramming KB188320