View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Gman Gman is offline
external usenet poster
 
Posts: 18
Default Opening a CHM file

I guess I should have included some explanation with my response. :-)

The code I posted before allows you to launch the CHM file -- as you
need. (The additional code enabled you to address specific topics within
the file. You would use that if, for example, you were implementing
context sensitive help).

Below, I've reposted the code but removed the extraneous details leaving
just that required to show a CHM file.

I've also changed it slightly so it's a function to which you just pass
the path, returning true if the launch failed.

So you would call it thus:

If not ViewHelpFile ("c:\myhelpfile.chm") then
MSGBOX "Sorry, couldn't launch the help file..."
End if

'Place at top of code module
Const HH_DISPLAY_TOPIC = &H0

Declare Function HtmlHelp Lib "hhctrl.ocx" Alias "HtmlHelpA" _
(ByVal hwndCaller As Long, ByVal pszFile As String, _
ByVal uCommand As Long, ByVal dwData As Long) As Long

Function ViewHelpFile(myFullPath as string) as boolean
'Returns true if file was successfully launched

Dim hwndHelp As Long
Dim hWnd As Long

'The return value is the window handle of the created help window.
hwndHelp = HtmlHelp(hWnd, myFullPath, HH_DISPLAY_TOPIC, 0)
If hwndHelp 0 then ViewHelpFile = true

End Sub



Avi Benita wrote:
Thanks for the prompt and detailed answer. But it seems to me that my
problem is a lot simpler. Actually, i have an all ready CHM file, and
all what i need is a macro that refers to it and opens it as is



*** Sent via Developersdex http://www.developersdex.com ***