?
Solved

How to open a help file within a Visual Basic application

Posted on 2003-03-21
9
Medium Priority
?
165 Views
Last Modified: 2013-11-25
Hi all,

I am currently testing a method before I add it to my official program. I would like to be able to click a command button and bring up a relevant topic in a help file.

Currently, I know that(under command1_click procedure):

Command1.HelpContextID = 10

will open the topic with an ID of 10 if the button is selected and you press "F1". However, this is not suitable for my purpose and I want it to open the topic on CLICKING the button.

I need this information ASAP. All comments and answers are welcome!!

Regards

CD
0
Comment
Question by:CDeath
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
9 Comments
 
LVL 5

Expert Comment

by:JohnMcCann
ID: 8181365
Private Declare Function OSWinHelp% Lib "user32" Alias "WinHelpA" (ByVal hWnd&, ByVal HelpFile$, ByVal wCommand%, dwData As Any)

Public Sub SearchForHelpOn(frm As Form)
Dim intRet As Integer
    'if there is no helpfile for this project display a message to the user
    'you can set the HelpFile for your application in the
    'Project Properties dialog
    If Len(App.HelpFile) = 0 Then
        MsgBox "Unable to display Search for help on. There is no Help associated with this project.", vbInformation, frm.Caption
    Else
        On Error Resume Next
        intRet = OSWinHelp(frm.hWnd, App.HelpFile, 261, 0)
        If Err Then
            MsgBox Err.Description
        End If
    End If
End Sub

Public Sub HelpContents(frm As Form)
Dim intRet As Integer
    'if there is no helpfile for this project display a message to the user
    'you can set the HelpFile for your application in the
    'Project Properties dialog
    If Len(App.HelpFile) = 0 Then
        MsgBox "Unable to display Help Contents. There is no Help associated with this project.", vbInformation, frm.Caption
    Else
        On Error Resume Next
        intRet = OSWinHelp(frm.hWnd, App.HelpFile, 3, 0)
        If Err Then
            MsgBox Err.Description
        End If
    End If
End Sub
0
 
LVL 5

Expert Comment

by:JohnMcCann
ID: 8181437
Const to use as wCommand

Const HELP_COMMAND = &H102&
Const HELP_CONTENTS = &H3&
Const HELP_CONTEXT = &H1
Const HELP_CONTEXTPOPUP = &H8&
Const HELP_FORCEFILE = &H9&
Const HELP_HELPONHELP = &H4
Const HELP_INDEX = &H3
Const HELP_KEY = &H101
Const HELP_MULTIKEY = &H201&
Const HELP_PARTIALKEY = &H105&
Const HELP_QUIT = &H2
Const HELP_SETCONTENTS = &H5&
Const HELP_SETINDEX = &H5
Const HELP_SETWINPOS = &H203&

OSWinHelp Me.hWnd, Me.HelpFile, HELP_CONTEXT, Command1.HelpContextID
0
 

Author Comment

by:CDeath
ID: 8181453
This is all well and good... but what about my "command1" command button that has to be clicked to display the help?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:CDeath
ID: 8181479
I dont understand where I have to put all this...
0
 

Author Comment

by:CDeath
ID: 8181488
I dont understand where I have to put all this...
0
 

Author Comment

by:CDeath
ID: 8181520
Oops double post...
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 400 total points
ID: 8181634
Try this:

Private Sub Command1_Click()
   Command1.HelpContextID = 10
   SendKeys "{F1}"
End Sub
0
 

Author Comment

by:CDeath
ID: 8181685
I tried copying the code in but it doesn't understand the "Me" part. I am a newbie to visual basic so you have to be gentle...
0
 

Author Comment

by:CDeath
ID: 8181696
Thank you so much!! So simple, you have saved my life =)
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question