Err.HelpFile Property

Syntax

Err.HelpFile

Description

A read/write string property that contains the fully qualified path of a Windows Help file.

Rules at a Glance

  • You can set a global Help file for the project in the project Properties dialog box, which can be accessed from the Tools menu in VB 4.0 and the Project menu in VB 5.0 and 6.0.

  • The HelpFile property is automatically set by the Err object when an error is raised.

  • The default help file is the Microsoft Visual Basic for Applications reference.

Example

See Err.HelpContext.

Programming Tips and Gotchas

  • You can display a topic from the Visual Basic help file by using the MsgBox function with the vbMsgBoxHelpButton constant and passing Err.HelpFile as the HelpFile argument (as shown in the example for the Err.HelpContext property). While this is a simple and effective way to add more functionality to your applications, bear in mind that some of your users could find the explanations within the VB help file somewhat confusing. If time and budget allow, the best method is to create your own help file (for which you need the Help compiler and other Help file resources from the full version of VB), and pass both the HelpContext and HelpFileName to MsgBox.

  • Another method of displaying the Help file is to call the Application.Help method, again passing both the Err.HelpFile and Err.HelpContext properties into the method, as follows:

    If Err.Number > 0 then
        Application.Help Err.HelpFile, Err.HelpContext
    End If

    This has the disadvantage that the help file page is shown immediately, without giving the user a chance to either recognize that an error has taken place or to skip displaying the Help file altogether.

  • Surprisingly, even if you have specified a Help file in the Project Properties dialog, the Err object defaults to the VBA help file. The only way to use another help file is to explicitly set the HelpFile property immediately prior to calling either the MsgBox function or the Application.Help method.

  • Some objects you may use within your application have their own help files, which you can access using HelpFile to display highly focused help to your users.

  • Remember that once the program encounters an Exit... statement or an On Error statement, all the properties of the Err object are reset; this includes the Help file. You must therefore set the Err.HelpFile property each time your application needs to access the help file.

See Also

Err.HelpContext Property, Err.Number Property, Chapter 6
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.140.198.12