Microsoft Office 2000/Visual Basic Programmer's Guide   

Creating a Help Button

In Excel and PowerPoint, you can use the Help method of the Application object to display a custom Help topic. But in Word and Access, you must use a call to the HtmlHelp or WinHelp API. In either case, implementing a Help button in a UserForm, Access form, or document is simply a matter of adding a command button to the form or document and defining a line of code to specify the Help file and context ID of the topic you want to display.

To use the Help method of the Application object in Excel, you would add a line like the following to the Help button's Click event procedure:

Application.Help ActiveWorkbook.Path & "\sample.chm", 2001

In PowerPoint, you would use the same line, but you'd use the ActivePresentation property to access the current path. For example:

Application.Help ActivePresentation.Path & "\sample.chm", 2001

For more information about using the Help method of the Application object, see "Displaying Help by Using the Help Method" later in this chapter.

To use the HtmlHelp API to display a Help topic, you must include a function declaration to use the HtmlHelp API in the Declarations section of a form, class, or standard module, and then add a line of code like the following to the Help button's Click event procedure:

Call HtmlHelp(0, ActiveDocument.Path &"\sample.chm", HH_HELP_CONTEXT, ByVal 2001&)

For more information about using a call to the HtmlHelp API to display a Help topic, see "Displaying Help by Using the HtmlHelp API" later in this chapter.