Help File

M

mangesh_yadav

Hi everyone,

I need some help on creating help files for an application made i
excel (and VBA). Any leads....

maybe something like a windows help file. I know a little about .ch
files, but nothing about creating windows help files.

- Manges
 
B

Bob Phillips

You can use HTML help files in an Excel application.

To invoke them, use some code like


Declare Function HtmlHelp Lib "hhctrl.ocx" _
Alias "HtmlHelpA" _
(ByVal hWnd As Long, _
ByVal lpHelpFile As String, _
ByVal wCommand As Long, _
ByVal dwData As Long) As Long

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.


Public Sub OpenHelp(ByVal ContextId As Long)
Dim hwndHelp As Long
'The return value is the window handle of the created help window.
Dim hwndHH
hwndHH = HtmlHelp(0, ThisWorkbook.Path & "\" & AppId & ".chm",
HH_HELP_CONTEXT, ContextId)
End Sub

where ContextId is defined in the HTML help file creation , and AppId is the
application name (assuming that is used for your help file).

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
M

mangesh_yadav

Thanks Bob,

When I tried to run your code, I get a runtime error '453': Can't fin
DLL entry point HtmlHelp in hhctrl.ocx

Is it something to do with the contextId that is passed to th
function.


By the way, I tried the following piece of code, but my excel shee
crashes when I run it.

''''''''''''''''' code starts here ''''''''''''''''''''''

Const HH_DISPLAY_TOPIC = &H0

Declare Function HtmlHelp Lib "hhctrl.ocx" Alias "HtmlHelpA" ()

Sub DisplayHTMLHelp()
Dim hwndHelp As Long
hwndHelp = HtmlHelp(0, "C:\WM.chm", HH_DISPLAY_TOPIC, 0)
End Sub

''''''''''''''''' code ends here ''''''''''''''''''''''

Any idea...!!!




- Manges
 
B

Bob Phillips

What was the bug Mangesh?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
M

mangesh_yadav

There was no bug in your code. I am using it nicely now. Somehow whil
trying to use it I must have commented a part and sometimes the fil
used to crash or sometimes i used to get the above error I mentioned.

But after uncommenting that part, it started working perfectly.

The bug that I introduced was:

I had empty brackets instead of the following

(ByVal hWnd As Long, _
ByVal lpHelpFile As String, _
ByVal wCommand As Long, _
ByVal dwData As Long)

- Manges
 
B

Bob Phillips

That's one of the problems with APIs, if you get the call wrong, it crashes
spectacularly.
 
Top