Microsoft Office 2000/Visual Basic Programmer's Guide |
Both the InputBox and MsgBox functions provide optional helpfile and context arguments that can be use to display a Help topic when a user clicks the Help button or presses F1. To display a custom Help topic, you must specify both optional arguments. The helpfile argument is a string value that specifies the Help file that contains the topic you want to display. This argument can accept either a .chm or .hlp file. The context argument specifies the mapped context ID of the topic to display.
If you specify the helpfile and context arguments when you are using the InputBox function, a Help button will automatically be added to the dialog box created by the InputBox function. If you specify the helpfile and context arguments when you are using the MsgBox function, you must also specify the vbMsgBoxHelpButton built-in constant in the buttons argument in order to add a Help button to the dialog box created by the MsgBox function.
The following code fragment shows how to display a Help topic when you are using the InputBox function:
InputBox Prompt:="Enter data", _
HelpFile:=strAppPath & "\sample.chm", _
Context:="2001"
The following line of code shows how to display a Help topic when you are using the MsgBox function:
MsgBox Prompt:= "You must enter a valid date.", _
Buttons:=vbMsgBoxHelpButton, _
HelpFile:= strAppPath & "\sample.chm", _
Context:= "2002"
The InputBox and MsgBox functions allow you to display a Help topic contained in a compiled HTML Help file in all Office applications, including Word and Access. There is no need to use the HtmlHelp API to display a Help topic in a .chm file when you are using these functions in Word and Access.