Microsoft KB Archive/296231

= OFFXPDEV: How to Create Context-Sensitive HTML Help Files =

Article ID: 296231

Article Last Modified on 2/12/2007

-

APPLIES TO


 * Microsoft Office XP Developer Edition
 * Microsoft Access 2002 Standard Edition

-



This article was previously published under Q296231



Moderate: Requires basic macro, coding, and interoperability skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

For a Microsoft Office 2000 Developer version of this article, see 242433.



SUMMARY
You can create Compressed HTML Help files (.chm) by using HTML Help Workshop included with Microsoft Office XP Developer.

This article demonstrates how to create a simple HTML Help file in HTML Help Workshop, and then how to use the Help file in a Microsoft Access form. The Help file uses context IDs to display different Help topics, depending on where you insert the pointer and click in the form.



MORE INFORMATION
The method of creating Help files presented here requires HTML Help Workshop. You can install it from the Microsoft Office XP Developer CD-ROM.

To create this sample HTML Help file, follow these steps:
 * 1) Create two HTML files: one for the form and one for the control.
 * 2) Create a map file to define the context IDs.
 * 3) Create an alias file that associates each topic ID with a topic.
 * 4) Compile these files in HTML Help Workshop into a single compressed HTML file (*.chm).
 * 5) Add the path to the HelpFile property of a sample form.
 * 6) Assign context IDs to the form and to a control on the form.
 * 7) Test the form.

The result is a form in which you can press F1 while in a particular text box to receive a Help topic specific to this text box. When you press F1 anywhere else on the form, the form-specific Help topic is displayed.

Creating the HTML Files
To create a compressed HTML file with context-sensitive Help, follow these steps:
 * 1) Click Start, point to Programs, point to HTML Help Workshop, and then click HTML Help Workshop.
 * 2) On the File menu, click New, click Project, and then click OK.

This starts the New Project Wizard. Click Next.
 * 1) In the New Project - Destination dialog box, name the project MyProject and click Next.
 * 2) Click Next, and then click Finish.
 * 3) On the File menu, click New.
 * 4) Select HTML File, and then click OK.
 * 5) In the HTML Title dialog box, type Form Help, and then click OK.
 * 6) Between the  tags, type This is the Help topic for the entire form.
 * 7) On the File menu, click Save File As.

The Save As dialog box appears.
 * 1) Save the file with the name Test1.htm. Make note of the folder in which you save this file.
 * 2) Close the Test1.htm file.
 * 3) On the File menu, click New.
 * 4) Click HTML File, and then click OK.
 * 5) In the HTML Title dialog box, type Control Help, and then click OK.
 * 6) Between the  tags, type This is the Help topic for the control.
 * 7) On the File menu, click Save File As.

The Save As dialog box appears.
 * 1) Save the file with the name Test2.htm. Make note of the folder in which you save the file.

Creating the Map File
 Click the Add/Remove topic files button.

It is the second button down on the Project tab. Add the two files that you created earlier: Test1.htm and Test2.htm. Click Start, and then click Run. In the Open box, type Notepad, and then click OK. In Notepad, type the following lines:


 * 1) define 1 1001


 * 1) define 2 2001

</li> On the File menu, click Save as.</li> In the Save as type box, change the type to All Files.</li> Type the file name Map.h, and then click Save. Note the location in which you save the file.</li></ol>

Creating the Alias File
<ol> In Notepad, click New on the File menu.</li> Type the following lines:

1=test1.htm;

2=test2.htm;

</li> On the File menu, click Save as.</li> In the Save as type box, change the type to All Files.</li> Type the file name Alias.h, click Save, and then quit Notepad.</li></ol>

Compiling a Single Compressed HTML File

 * 1) In HTML Help Workshop, click the HTMLHelp API Information button.

This is the fourth button down on the left side of the Project tab.
 * 1) On the Map tab, click Header File.
 * 2) Click Browse, and then browse to the Map.h file that you created earlier in Notepad.
 * 3) Select Map.h, click Open, and then click OK.
 * 4) Click the Alias tab, and then click Include.
 * 5) Click Browse, and then browse to the Alias.h file that you created earlier in Notepad.
 * 6) Select Alias.h, click Open, and then click OK.
 * 7) Click OK.
 * 8) On the File menu, click Compile. Click Yes when asked if you want to save files first.
 * 9) Compile the Help file as MyProject.
 * 10) Verify that the MyProject.chm file has been created, and make note of its location.

Adding the Path
<ol> In Microsoft Access, create a new database named Database1.mdb. Create it in the same location in which you created the Help file.</li>  In the Database1.mdb file, create the following form: <pre class="fixed_text">  Form: Test1 -  Caption: TestForm

Text box Name: Field1

Text box Name: Field2 </li> In Design view, click the form, and then click Properties on the View menu.</li> Click the Other tab.</li> Set the HelpFile property to MyProject.chm.</li></ol>

Assigning Context IDs

 * 1) Set the HelpContextId property of the form to 1001, and then press ENTER.
 * 2) Select the Field2 control, and then click Properties on the View menu.
 * 3) Click the Other tab.
 * 4) Set the HelpContextId property of the Field2 control to 2001. Press ENTER.

Testing the Form

 * 1) On the View menu, click Form View.
 * 2) Click the Field1 control, and then press F1.

Note that the topic for the form appears. This is because the Field1 control does not have an associated topic and therefore it defaults to the general form topic.
 * 1) Close the Help topic.
 * 2) Click the Field2 control, and then press F1.

Note that the topic for the Field2 control is displayed.

<div class="references_section">