Displaying Help from VBA Code
There are two ways to display a custom Help topic from code. In Excel and PowerPoint, you can use the Help method of the Application object, but in Word and Access you must use an API call to HTML Help or to WinHelp to display the Help topic. The following sections describe how to do both, and also detail how to display Help topics from the InputBox and MsgBox functions, how to display Help topics when error messages are displayed, and how to associate Help topics with properties and methods in class modules.
In This Section
- Displaying Help by Using the Help Method
The Help method of the Application object can be used from Excel and PowerPoint to display a custom Help topic. - Displaying Help by Using the HtmlHelp API
Because the current implementation of the HTML Help ActiveX control can't be inserted in a form and doesn't provide Component Object Model (COM) interfaces, you must call its API directly if you must use features beyond those supported by the methods and properties available in VBA. - Displaying Help by Using the InputBox and MsgBox Functions
Both the InputBox and MsgBox functions provide optional helpfile and context arguments that can be used to display a Help topic when a user clicks the Help button or presses F1. - Displaying Help for Custom Error Messages
The Raise method of the Err object has optional helpfile and helpcontext arguments that set the HelpFile and HelpContext properties of the Err object to the specified Help file name and context ID when your custom error is triggered. - Displaying Help for Properties and Methods in Class Modules
You can add Help information for the custom properties and methods in your class modules.
Related Sections
- Adding Help to Your Office Application
Adding online Help to your Microsoft Office application can reduce the amount of time required to train and support users of your applications. - Displaying Help Topics
You can display Help topics to assist users of your Office applications several different ways. - Maintaining Backward Compatibility with Office 97/2000 Applications
If your application must maintain backward compatibility with Office 97 and Office 2000 applications, you should supply all Help authored and compiled as WinHelp 4.0 files by using Microsoft Help Workshop or some other WinHelp 4.0 authoring tool. - The Kinds of Help You Can Use
You can create context-sensitive Help for dialog boxes created by using UserForms or Access forms. You can also create context-sensitive Help for command bar controls. - Creating a Help File to Use with an Office Application
Office XP applications can display standard Help topics authored and compiled by using either HTML Help (.chm) or WinHelp 4.0 (.hlp). Context-sensitive Help for Office XP applications must be authored by using WinHelp 4.0. - Specifying the Path to Your Application's Help File
To display Help for your application, you must specify the path to the Help file that contains the topics you want to display. - Displaying Help in Forms and Documents
In UserForms and Access forms, you can display context-sensitive Help for interface elements, and you can display standard Help topics from a Help button on the form. - Displaying Help from Command Bars
You can display context-sensitive Help for custom command bar controls, and call a standard Help topic when a user clicks a toolbar button or menu item. - Using the Office Assistant to Display Help
You can use the Office Assistant to display a balloon that allows users to access custom Help topics.