How to get TOC shown in HTML Help when calling from VBA?
The workbook created from a template file has no knowledge of the location
of the template or any other association with it. In fact, if a template
has a workbook_open event, to avoid having the code run when the template is
edited, people add code to check if the workbook has a path - if it doesn't
they know it is not the template being opened but a workbook created from
the template.
Sounds like you need to distribute your program with an install routine.
--
Regards,
Tom Ogilvy
"myunker" wrote in message
...
Thanks Mat - that did the trick.
Additional issue now arises. My Excel spreadsheets are templates that I
am
producing for some elementary school teachers. I KNOW they will simply
put
these templates on some given disk on their system (e.g. their local
account)
rather than in the templates directory. In so doing, when the template
is
opened I don't see how I can determine where the original template
location
was so that I can access the Help file. I can do a "file search " of
course,
but depending on their server setup that could take hours to complete.
Any idea on how to determine where the template file was located? That
way
the "new" workbook can find where the Help file was also installed and I
can
then save the help file along with the new file. As it stands now the new
workbook tries to get the help file from "C:\" since it hasn't been saved
anywhere.
thanks
"Mat P:son" wrote:
Instead of using the Application.Help method you can call the proper
HTML Help:
==========================
' Used for the HtmlHelp() Win32 function
Private Const HhDisplayTopic As Long = &H0
Private Const HhHelpContext As Long = &HF
' Names on the HTML Help file and the HTML Help window
' TODO: Fill in your own names here!!!
Private Const XlHelpFile As String = "\XlAddIn.chm"
Private Const XlHelpWin As String = "Main"
Private Const XlHelpEntry As String = "Welcome.htm"
' The function declaration for HTML Help
' TODO: HHCtrl.ocx should already be present on all systems except
' perhaps some old NT4 boxes. Install HTML Help if/when required!
Private Declare Function HtmlHelp Lib "hhctrl.ocx" Alias "HtmlHelpA" ( _
ByVal hwndCaller As Long, _
ByVal pszFile As String, _
ByVal uCommand As Long, _
dwData As Any) As Long
....
Private Sub ShowHtmlHelp()
' Show HTML Help for the add-in: the CHM file should be located
' in the same folder as the add-in, and we're opening the home page
Dim lResult As Long
lResult = HtmlHelp( _
0, _
ThisWorkbook.Path & XlHelpFile & "" & XlHelpWin, _
HhDisplayTopic, _
ByVal XlHelpEntry)
If lResult = 0 Then
' Handle the error...
End If
End Sub
==========================
"myunker" wrote:
I have built a Help file using HTML Help Workshop (.chm file). When I
call
the file from VBA (application.help filename) all I see is my default
page.
There is no TOC, or search, or any other options that I see if I
simply open
the .chm file by itself.
Any help would be appreciated.
|