The second way to include Help in an application, specifying the filename at
runtime, is more flexible than setting the project properties for the file at design time. With
this method, different users have the ability to reference different Help files, or a single
user can use different Help files depending on how the application is being used.
As an example, imagine that you are creating an accounting system that will
be used by both a data entry group and the financial analysis staff of a company. The data entry
group will use the windows of the application to enter and change data in the system. The
financial analysis group may require read-only access to the data. You may want to provide
customized Help files to each group, describing their own needs within the application. If you
limit yourself to setting the Help file of the application just at design time, you could only
provide a single Help file. By setting the Help file at runtime, you are not constrained to
a single file.
You can use the HelpFile property of the App object to set a reference to a Help
file at runtime. The App object is a global object available to the application. It provides
information about the application as well as the means to change some of the characteristics
of the application.
The HelpFile property initially identifies the Help file that was entered into
the Project Properties dialog box at design time (refer back to Figure 7.3). App.Helpfile
is a read/write property at runtime, so you can reset the Help file after the application
has started. You can set a Help file at runtime with code as follows:
App.HelpFile = filename
Filename is the Help file's name, including, if necessary, a path to that
file. To set a reference to your own Help file, for example, you might write the following code:
Usually, if an application needs to set the Help file path at
runtime, it will get the data it needs from previously stored information in the
System Registry. Occasionally, the user may need to specify the file name, and
sometimes the path to that file. The HelpFile property is a text string that describes
the path and file. If the path is not defined, the application follows the standard
Windows search methods just as it does when you identify the file at design time.