Assigning Help Files and Topic IDs in a Visual Basic Project

Last reviewed: February 27, 1998
Article ID: Q173710
The information in this article applies to:
  • Microsoft Excel 97 for Windows

SUMMARY

This article describes how to configure a Visual Basic for Applications project to use a specific Help file. The ActiveX and Forms controls in a UserForm can use context-sensitive Help to display Help topics in the Help file.

MORE INFORMATION

Assigning a Help File to a Project

Configuring a Visual Basic project to use a particular Help file allows you to assign a Help topic identification number to a control on a UserForm. When you select the control and press F1, the topic in the Help file appears. To assign a Help file to a project, follow these steps:

  1. In the Visual Basic Editor (press ALT+F11), right-click any object in the project in the Project Explorer and click VBAProject Properties.

  2. In the "VBAProject - Project Properties" dialog box, type the path and file name of the Help file in the Help File Name box or click the button to the right of the box to find the Help file. Click OK.

Assigning a Help Topic to an Office Form Control

To assign a Help topic ID to an existing Office form control, follow these steps:

  1. In the Visual Basic Editor (press ALT+F11), display the UserForm with the control, and then right-click the control and click Properties.

  2. In the Properties window, set the HelpContextId property to the topic ID for the topic you want to appear when F1 is pressed.

Assigning a Help File and Topic at Run Time

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

   http://www.microsoft.com/supportnet/refguide/

You can also assign the Help file and Help topic ID at run time by specifying the HelpFile property for the project and the HelpContextId property for the control. To assign a Help file and topic, follow these steps:

  1. Display the Code window for the UserForm by right-clicking the UserForm and clicking View Code. Click UserForm in the Object list. Click Activate in the Procedure list and type the following code in a Sub procedure

          Application.VBE.VBProjects<project>.HelpFile = <help file>
          <object>.HelpContextId = <value>
    

    where <project> is the name of the Visual Basic project.

    NOTE: You can use the ActiveProject property instead as in the following example:

          Application.VBE.ActiveProject.HelpFile = "C:\myHelp.hlp"
    

    Note that <help file> is the path and file name of the Help file and <object> is the object name of the ActiveX control on the UserForm. For example, if you are using the Toolbar control, the statement is similar to the following:

          Toolbar1.HelpContextId = 1
    

    Also, <value> is the Help topic ID you want to appear when Help is displayed.

Assigning a Help Topic to an ActiveX Control

To assign a Help topic ID to an ActiveX control, use the HelpCommand and HelpContext properties. To assign a Help topic ID to an ActiveX control, follow these steps:

  1. In the Visual Basic Editor (press ALT+F11), display the UserForm with the ActiveX control, and then double-click the UserForm.

  2. In the Code window for the UserForm, click UserForm in the Object list. Click Activate in the Procedure list. Type the following code in a Sub procedure

          Application.VBE.VBProjects<project>.HelpCommand = cdlHelpContext
          <control>.HelpContext = <value>
    

    where <project> is the name of the Visual Basic project.

    NOTE: You can use the ActiveProject object instead as in the following example:

          Application.VBE.ActiveProject.HelpCommand = cdlHelpContext
    

    Note that <control> is the name of the ActiveX control. For example if you are using the Slider control, the statement is similar to the following:

          Slider1.HelpContext = 10
    

    Also, <value> is the Help topic ID you want to appear when Help is displayed.

REFERENCES

For more information about context-sensitive Help in a project, click the Index tab in Microsoft Visual Basic Help, type the following text

   helpcontextid

and then double-click the selected text to go to the "HelpContextId Property" topic.


Additional query words: XL97 helpid vbaxl8.hlp xlmain8.hlp
Keywords : kbprg
Version : WINDOWS:97
Platform : WINDOWS
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 27, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.