Microsoft KB Archive/173710

From BetaArchive Wiki

Article ID: 173710

Article Last Modified on 11/23/2006



APPLIES TO

  • Microsoft Excel 97 Standard Edition



This article was previously published under Q173710

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 professionals 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 a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site:

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:

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 ActiveVBProject property instead, as in the following example:

     Application.VBE.ActiveVBProject.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 ActiveVBProject object instead as in the following example:

       Application.VBE.ActiveVBProject.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 OFF97

Keywords: kbhowto kbprogramming KB173710