Knowledge Base |

# How to Run a WinHelp Macro from a Help File

Article ID: 104165

Article Last Modified on 12/9/2003

APPLIES TO

- Microsoft Visual Basic 1.0 Standard Edition
- Microsoft Visual Basic 2.0 Standard Edition
- Microsoft Visual Basic 3.0 Professional Edition
- Microsoft Visual Basic 2.0 Professional Edition
- Microsoft Visual Basic 3.0 Professional Edition

This article was previously published under Q104165

## SUMMARY

This article shows by example how to invoke WinHelp macros in a Help file upon first entering a topic or upon clicking a hot spot. The examples show you how to modify the example help topic source file VB\HC\ICONWRKS.RTF using Microsoft Word version 2.0 for Windows. After making the changes and compiling the .RTF file into a Help file (.HLP file), you will be able to execute a macro upon first entering the topic or upon clicking a hot spot.

## MORE INFORMATION

To run a macro when a topic is first entered, enter the macro call into a custom footnote with an exclamation (!) as the footnote mark. To do this in Microsoft Word version 2.0 for Windows, follow these steps:

1. Open the file VB\HC\ICONWRKS.RTF.
2. Locate the beginning of this topic heading:
   Editor: Commands and Tools
   Place the text caret at the beginning of the line, in front of the pound (#) character.
3. From the Insert menu, choose Footnote and select Custom Footnote Mark. Enter the exclamation mark (!) and choose the OK button. The Footnotes area appears at the bottom of the window with the caret on a line that begins with the exclamation mark (!).
4. Enter this text:
   About()
5. To save this change, from the File menu, choose Close. In each of the subsequent three dialogs, press the Enter key to select the default button.
6. At the command prompt, set the current directory to VB\HC. Then enter the following command to compile the help file:
   HC31 ICONWRKS.HPJ
7. Load the resulting ICONWRKS.HLP file into WINHELP.EXE. To do this in the Program Manager, from the File menu, choose Run. Then enter the full path of VB\HC\ICONWRKS.HLP. The IconWorks help file appears.
8. Click the hot spot Commands and Tools to jump to the topic that contains the macro call. When the topic appears, the About() macro displays a dialog box titled About Help.

To run a macro immediately when a hot spot is clicked, format the hot spot text as double-underlined text followed by an exclamation mark (!) and the macro call -- both formatted as hidden text. To do this in Microsoft Word version 2.0 for Windows, follow these steps:

1. Open the file VB\HC\ICONWRKS.RTF.
2. From the Tools menu, choose Options. Select the View Category. In the section labeled Nonprinting Characters, check Paragraph Marks and Hidden Text.
3. Place the text caret at the beginning of the second line of the file (the line following the heading). Enter the text "Call Macro!About()" without the quotation marks, and press the Enter key.
4. Select the text "Call Macro" up to but not including the exclamation mark. From the Format menu, choose Character. Change the setting in the combo box labeled Underline from None to Double. Choose the OK button.
5. Select the text "!About()" up to but not including the paragraph character at the end of the line. From the Format menu, choose Character. In the Style section, check Hidden.
6. Close the file. Compile it using the Help compiler (HC31.EXE). Then view the compiled .HLP file using WINHELP.EXE. See the previous example for an explanation of how to do this.
7. Click the Call Macro hot spot. The About() macro displays a dialog box titled About Help.

Additional query words: 3.00

Keywords: KB104165