Microsoft Office 2000/Visual Basic Programmer's Guide   

Displaying Context-Sensitive Help in UserForms

Implementing context-sensitive Help for interface elements in UserForms is the same regardless of which Office application the form will be used with.

To define context-sensitive Help for UserForms

  1. Create a WinHelp 4.0 Help file that contains the Help topics you want to display. For more information about creating a Help file, see "Creating a Help File to Use with an Office Solution" earlier in this chapter.

  2. Open the Visual Basic Editor in the application you are working with.

  3. In the Project Explorer, right-click the name of the VBA project for the document you are working with, and then click Project Properties.

  4. In the Help File Name box, specify the full path and name of the Help file that contains context-sensitive Help topics.

    If you don't want to include the full path to the Help file, omit steps 3 and 4 and add code to the form's Initialize event that specifies the path by using the HelpFile and Path properties of the document. For example:

    Dim strHelpPath As String
    
    strHelpPath = ActiveDocument.Path & "\samplepopups.hlp"
    
    ActiveDocument.VBProject.HelpFile = strHelpPath
    

    Note   You can specify only one Help file per VBA project. If you want to define context-sensitive Help for more than one UserForm or for class modules in the project, the Help file you specify must contain Help topics for all of these items.

  5. Open the UserForm you want to work with, and set the form's WhatsThisButton and WhatsThisHelp properties to True.

  6. For each control that you want to display context-sensitive Help for, set the control's HelpContextID property to the context ID of the Help topic you want to display for that control.