Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
avi avi is offline
external usenet poster
 
Posts: 195
Default Opening a CHM file

Hello,

How do i open a CHM(help) file with a macro?

Thanks


Avi Benita www.avibenita.com


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Opening a CHM file

Code I use.... but not written by me:

Option Explicit
Option Private Module

Const HH_DISPLAY_TOPIC = &H0
Const HH_SET_WIN_TYPE = &H4
Const HH_GET_WIN_TYPE = &H5
Const HH_GET_WIN_HANDLE = &H6
Const HH_DISPLAY_TEXT_POPUP = &HE ' Display string resource ID or
' text in a pop-up window.
Const HH_HELP_CONTEXT = &HF ' Display mapped numeric value in
' dwData.
Const HH_TP_HELP_CONTEXTMENU = &H10 ' Text pop-up help, similar to
' WinHelp's HELP_CONTEXTMENU.
Const HH_TP_HELP_WM_HELP = &H11 ' text pop-up help, similar to
' WinHelp's HELP_WM_HELP.

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


' HTML Help file launched in response to a button click:
Private Sub ViewHelpFile()

' hWnd is a Long defined elsewhere to be the window handle
' that will be the parent to the help window.

Dim hwndHelp As Long
Dim hWnd As Long

' The return value is the window handle of the created help window.
hwndHelp = HtmlHelp(hWnd, "myfile.chm", HH_DISPLAY_TOPIC, 0)

End Sub


' ' A specific topic identified by the variable ContextID is launched
' ' in response to this button click:
Private Sub HH_HELP_Click()
Dim hwndHelp As Long
'The return value is the window handle of the created help window.
hwndHelp = HtmlHelp(hWnd, "myfile.chm", HH_HELP_CONTEXT, ContextID)
End Sub



Avi wrote:
Hello,

How do i open a CHM(help) file with a macro?

Thanks


Avi Benita www.avibenita.com


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Opening a CHM file


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 ***
  #4   Report Post  
Posted to microsoft.public.excel.programming
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 ***

  #5   Report Post  
Posted to microsoft.public.excel.programming
avi avi is offline
external usenet poster
 
Posts: 195
Default Opening a CHM file

Many thanks. Works perfectly...

Avi


Avi Benita 054-4660641 wwwAvi Benita 054-4660641 www.avibenita.com
"Gman" <nah wrote in message ...
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 ***



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
opening a file in Excel starts application but dose not open file Bob Shelton Excel Discussion (Misc queries) 1 July 2nd 08 07:51 PM
File:1 and File:2 -- Double Files when Opening One File dallin Excel Discussion (Misc queries) 1 January 25th 07 02:53 AM
opening an excel file opens a duplicate file of the same file skm Excel Discussion (Misc queries) 1 December 7th 05 05:52 PM
Error:Invalid File format,while opening an Excel Template file Saurabh Excel Programming 1 January 17th 05 07:15 AM


All times are GMT +1. The time now is 01:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"