D
Dan Bair
Hi;
I've asked this question before and got a good answer
from "Dave", but I guess I'm too dense to figure it out.
I'm developing in Office XP. I have a help file called
Project.hlp My "help" is working fine; when I
press "F1", the right help topic comes up for the right
form! Cool!
PROBLEM: Now what I want to do is "emulate"
pressing "F1" from the toolbar. In other words, I want
to be able to have a toolbar menu item called "Help".
When the user clicks on "Help", I want it to execute a
module that figures out what VBA form has focus and bring
up the help topic that matches that form's
helpcontextid. The module would have to look for the
help file in the same path/directory that my VBA project
is in.
Like I said, "Dave" gave me some code for the module and
I tried to use it, but can't even get it to compile.
Code is marked in red and I can't figure out what's wrong
with it. I'm pretty new at VBA coding.
DAVE'S RESPONSE:
Place the following function in a module, and then call
it
from the button click event, passing the the full path of
the helpfile and the contextID
Function OpenHelpWithContextID(ByVal strHelpFileName As _
String, lngContextID As Long)
' Opens the Help file to ContextID.
WinHelp Application.hWndAccessApp, ByVal strHelpFileName,
_
HELP_CONTEXT, ByVal lngContextID
End Function
You need to place this constant
Public Const HELP_CONTEXT = &H1
In the general section of the module and this also
Declare Sub WinHelp Lib "user32" Alias _
"WinHelpA" (ByVal hWnd As Long, ByVal lpHelpFile As
String, _
ByVal wCommand As Long, ByVal dwData As Any)
--------------------------------------------------------
I can't get the "Declare" code to compile. Can somebody
give me another clue?
Thanks,
Dan
I've asked this question before and got a good answer
from "Dave", but I guess I'm too dense to figure it out.
I'm developing in Office XP. I have a help file called
Project.hlp My "help" is working fine; when I
press "F1", the right help topic comes up for the right
form! Cool!
PROBLEM: Now what I want to do is "emulate"
pressing "F1" from the toolbar. In other words, I want
to be able to have a toolbar menu item called "Help".
When the user clicks on "Help", I want it to execute a
module that figures out what VBA form has focus and bring
up the help topic that matches that form's
helpcontextid. The module would have to look for the
help file in the same path/directory that my VBA project
is in.
Like I said, "Dave" gave me some code for the module and
I tried to use it, but can't even get it to compile.
Code is marked in red and I can't figure out what's wrong
with it. I'm pretty new at VBA coding.
DAVE'S RESPONSE:
Place the following function in a module, and then call
it
from the button click event, passing the the full path of
the helpfile and the contextID
Function OpenHelpWithContextID(ByVal strHelpFileName As _
String, lngContextID As Long)
' Opens the Help file to ContextID.
WinHelp Application.hWndAccessApp, ByVal strHelpFileName,
_
HELP_CONTEXT, ByVal lngContextID
End Function
You need to place this constant
Public Const HELP_CONTEXT = &H1
In the general section of the module and this also
Declare Sub WinHelp Lib "user32" Alias _
"WinHelpA" (ByVal hWnd As Long, ByVal lpHelpFile As
String, _
ByVal wCommand As Long, ByVal dwData As Any)
--------------------------------------------------------
I can't get the "Declare" code to compile. Can somebody
give me another clue?
Thanks,
Dan