Skip to main content

Err object HelpContext property

Table of contents
  1. Remarks
  2. Examples

Returns or sets a string expression containing the context ID for a topic in a Help file. Read/write.

Remarks

The HelpContext property is used to automatically display the Help topic specified in the HelpFile property.

If both HelpFile and HelpContext are empty, the value of Number is checked. If Number corresponds to a Visual Basic run-time error value, the Visual Basic Help context ID for the error is used. If the Number value doesn't correspond to a Visual Basic error, the contents screen for the Visual Basic Help file is displayed.

Examples

This example uses the HelpContext property of the Err object to show the Visual Basic Help topic for the Overflow error.

Dim Msg
Err.Clear
On Error Resume Next
Err.Raise 6 ' Generate "Overflow" error.
If Err.Number <> 0 Then
    Msg = "Press F1 or HELP to see " & Err.HelpFile & " topic for" & _
    " the following HelpContext: " & Err. HelpContext
    MsgBox Msg, , "Error: " & Err.Description, Err.HelpFile, _
Err.HelpContext
End If

Leave a comment

Your email address will not be published. Required fields are marked *

Format your code: <pre><code class="language-vba">place your code here</code></pre>