OFFXPDEV: How to Create Context-Sensitive HTML Help Files (296231)



The information in this article applies to:

  • Microsoft Office XP Developer
  • Microsoft Access 2002

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.
  3. In the New Project - Destination dialog box, name the project MyProject and click Next.
  4. Click Next, and then click Finish.
  5. On the File menu, click New.
  6. Select HTML File, and then click OK.
  7. In the HTML Title dialog box, type Form Help, and then click OK.
  8. Between the <BODY> tags, type This is the Help topic for the entire form.
  9. On the File menu, click Save File As.

    The Save As dialog box appears.
  10. Save the file with the name Test1.htm. Make note of the folder in which you save this file.
  11. Close the Test1.htm file.
  12. On the File menu, click New.
  13. Click HTML File, and then click OK.
  14. In the HTML Title dialog box, type Control Help, and then click OK.
  15. Between the <BODY> tags, type This is the Help topic for the control.
  16. On the File menu, click Save File As.

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

Creating the Map File

  1. Click the Add/Remove topic files button.

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

    #define 1 1001
    #define 2 2001

  6. On the File menu, click Save as.
  7. In the Save as type box, change the type to All Files.
  8. Type the file name Map.h, and then click Save. Note the location in which you save the file.

Creating the Alias File

  1. In Notepad, click New on the File menu.
  2. Type the following lines:

    1=test1.htm;
    2=test2.htm;

  3. On the File menu, click Save as.
  4. In the Save as type box, change the type to All Files.
  5. Type the file name Alias.h, click Save, and then quit Notepad.

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.
  2. On the Map tab, click Header File.
  3. Click Browse, and then browse to the Map.h file that you created earlier in Notepad.
  4. Select Map.h, click Open, and then click OK.
  5. Click the Alias tab, and then click Include.
  6. Click Browse, and then browse to the Alias.h file that you created earlier in Notepad.
  7. Select Alias.h, click Open, and then click OK.
  8. Click OK.
  9. On the File menu, click Compile. Click Yes when asked if you want to save files first.
  10. Compile the Help file as MyProject.
  11. Verify that the MyProject.chm file has been created, and make note of its location.

Adding the Path

  1. In Microsoft Access, create a new database named Database1.mdb. Create it in the same location in which you created the Help file.
  2. In the Database1.mdb file, create the following form:
       Form: Test1
       -----------------
       Caption: TestForm
    
       Text box
       ------------
       Name: Field1
    
       Text box
       ------------
       Name: Field2
    					
  3. In Design view, click the form, and then click Properties on the View menu.
  4. Click the Other tab.
  5. Set the HelpFile property to MyProject.chm.

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.
  3. Close the Help topic.
  4. Click the Field2 control, and then press F1.

    Note that the topic for the Field2 control is displayed.

REFERENCES

For more information about creating header files, click Microsoft HTML Help Workshop Help on the Help menu, type header files in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.

Modification Type:MajorLast Reviewed:5/9/2003
Keywords:kbhowto kbinfo KB296231