Help for Custom Dialog Boxes

If you are using Visual Basic to create custom dialog boxes (with UserForms), you can use one of two methods for displaying Help for these dialog boxes. The method used is determined by the WhatsThisButton and WhatsThisHelp properties of the UserForm. To use these properties, you must first assign a custom Help file to your VBProject using its HelpFile property. You can do this with code or with the Project Properties dialog box (shown below). The following example demonstrates how to set the custom Help file CustHlp.hlp as the custom Help file for your project.

Sub AddCustomHelpFileToProject()
      Dim szHLP as string
      szHLP = Thisworkbook.Path & "\CustHlp.hlp"
    Application.VBE.VBProjects("vbaHelpTest").HelpFile = szHLP
End Sub

From the Tools menu, choose the VBAProject Properties menu, and you can set the same property via the following dialog box.

Once you have set a custom Help file for you project, the table below shows the effect of various combinations of the WhatsThisButton and WhatsThisHelp properties of the UserForm.

WhatsThisButton

WhatsThisHelp

Effect

True

True

Displays the WhatsThis icon in the upper right corner of the UserForm. Clicking this icon and then clicking a control displays the Help topic for that control in a control tip-style window.

False

True

No WhatsThis icon is displayed on the UserForm. When the f1 key is pressed, the Help topic for the currently active control is displayed in a control tip-style window.

False

False

No WhatsThis icon is displayed on the UserForm. When the f1 key is pressed, the Help topic for the currently active control is displayed in a normal help window.


If there is no Help context ID specified for the currently active control when the f1 key is pressed or it is clicked with the WhatsThis cursor, then nothing happens.