Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Calling Help file

Posted on 2002-04-17
9
Medium Priority
?
210 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 200 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

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
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…
Suggested Courses

972 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