Solved

Calling Help file

Posted on 2002-04-17
9
202 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
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
 
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now