Solved

Calling Help file

Posted on 2002-04-17
9
206 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
Technology Partners: 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!

 
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to debug this code 7 65
passing a value with stream reader AFTER a ";" 3 92
VB 6 error 5 in windows 10 but not in XP 7 72
Dinamic report to Crosstab query 9 60
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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 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…

738 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