Solved

Calling Help file

Posted on 2002-04-17
9
203 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

929 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

9 Experts available now in Live!

Get 1:1 Help Now