Solved

Calling Help file

Posted on 2002-04-17
9
207 Views
Last Modified: 2010-05-02
I need to call an help file (.chm file) from my VB application. I have set the the path of the help file to App.HelpFile. Now, when i call the help file by pressing F1 it works fine. But, i am not able to call the help file from the menu in MDIform. Just i am using Sendkeys to invoke the help file.

Private Sub mnuHelp_Click()
   SendKeys "{F1}", True
End Sub

Can any one help me in this regard? Is there anyother way to call the help file?
0
Comment
Question by:nmkrishna
[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
9 Comments
 
LVL 2

Expert Comment

by:skhorshid
ID: 6948149
cant you use a commondialog control aswell
0
 
LVL 4

Expert Comment

by:chabaud
ID: 6948258
Could try:

Shell App.HelpFile
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6948270
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.

 
LVL 20

Expert Comment

by:hes
ID: 6948320
Try

Private Sub mnuHelp_Click()
  'hh.exe is the view for compiled help (CHM) files
    Dim i As Long
    i = Shell("hh.exe " & App.HelpFile & "\Yourhelp.chm", vbNormalFocus)End Sub

0
 
LVL 15

Accepted Solution

by:
ameba earned 50 total points
ID: 6948490
' Here is a quick test
Option Explicit
Private Declare Function HtmlHelp Lib "hhctrl.ocx" Alias "HtmlHelpA" _
    (ByVal hwndCaller As Long, ByVal lpHelpFile As String, ByVal wCommand _
    As Long, ByVal dwData As Long) As Long
Private Const HH_DISPLAY_TOC = &H1
Private Const HH_DISPLAY_INDEX = &H2
Private Const HH_DISPLAY_SEARCH = &H3

Private Sub Form_Click()
    App.HelpFile = "c:\windows\help\msoe.chm"   ' App.Path & "\appname.chm"
    Call HtmlHelp(Me.hWnd, App.HelpFile, HH_DISPLAY_TOC, 0)
End Sub


Sometimes, if you use Project Properties to set helpfile, vb will set it to the full path, e.g.: "c:\vbproject\test.chm", which can be incorrect path on user's PC.
The solution is to set help file when app starts (e.g. in MDIForm_Load):
    App.HelpFile = App.Path & "\appname.chm"
0
 
LVL 2

Expert Comment

by:Ber
ID: 6949383
All of the above calling HTML help(hh.exe) will not open this format of help file. To open the file you could use the shellExecute API as shown below

In a module add the following

Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Public Const SW_SHOWNORMAL = 1


Modify the Click event in your code as shown below...
Private Sub mnuHelp_Click()

Dim lSuccess As Long

'this line will open your helpfile
lSuccess = ShellExecute(Me.hWnd, "open" ,App.Helpfile , vbNullString, vbNullString, SW_SHOWNORMAL)

End Sub

This should do the job...
Cheers...
Ber...
0
 

Author Comment

by:nmkrishna
ID: 6949743
Hi All,

Thanks a lot for your valuable suggestions. Using Shell command works fine. But, if i click the menu twice two help windows are open.

The solution by ameba works fine.

Thanks
0
 
LVL 15

Expert Comment

by:ameba
ID: 6950299
Thank you!
0
 
LVL 1

Expert Comment

by:jimboVB
ID: 7789303
Ermm... I know this is not quite right.. but i also have the same problem. But when i use ameba's solution i still have a little problem.

Qn
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20464925.html

Thanks
Jimbo
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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 Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month7 days, 23 hours left to enroll

617 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