Name
Err.HelpContext Property
Data Type
Long
Description
A read/write property that either sets or returns a long integer value containing the context ID of the appropriate topic within a Help file.
Rules at a Glance
The HelpContext property can be set either directly or by supplying the fifth parameter (the
helpcontextparameter) to the Err.Raise method.HelpContext IDs are decided upon when writing and creating a Windows help file. Once the Help or HTML help file has been compiled, the IDs can’t be changed. Each ID points to a separate Help topic.
Example
On Error Resume Next
Dim i
i = 8
MsgBox (i / 0)
If Err.Number <> 0 Then
Err.Description = "You are attempting to divide by zero."
Err.Helpfile = "C:\Windows\help\CustomApp.CHM"
Err.HelpContext = 1000000 + Err.Number
MsgBox Err.Description, vbMsgBoxHelpButton, "Error", Err.HelpFile, _
Err.HelpContext
End IfProgramming Tips and Gotchas
You can display a topic from a help file by supplying values to the Err.HelpFile and Err.HelpContext properties, using the MsgBox function with the
vbMsgBoxHelpButtonconstant and passingErr.HelpContextas theHelpContextargument (as shown in the previous example).If you supply a HelpContext ID that can’t be found in a Windows Help file, the contents page for the Help file should be displayed. However, what actually happens is that a Windows Help error is generated, and a message box is displayed that informs the user to contact their vendor. If you supply a HelpContextID that cannot be found in an HTML ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access