Displaying Help Topics with the MsgBox Function

To display Help using the Visual Basic MsgBox function, you must include in its list of arguments a Help file name and topic number. This causes a Help button to be displayed in the message box, and specifies which Help topic will be displayed when the Help button is chosen. For example, in Microsoft Excel for Windows, enter:

MsgBox("Delete this item?",vbOKCancel,,"REPORTS.HLP",501)

Help topics are assigned to CommandBarControls using the HelpFile and HelpContextID properties. The following example demonstrates how to assign the Help topic number 101 from the custom Help file custhlp.hlp to a custom CommandBarControl.

Sub AddHelpToCommandBarControl()
    With CommandBars("MyBar").Controls(1)
        .HelpFile = ThisWorkbook.Path & "\custhlp.hlp"
        .HelpContextID = 101
    End With
End Sub