Calling custom .chm from Access Help button
For many months, I have been all over the net in various user groups and forums asking how to repurpose the Access 2007 Help Icon button so it calls my custom Help file. I packaged a custom application in Runtime and Microsoft disables the Help Icon in Runtime but leaves it on the command bar. I didn’t want the users to get confused and click on the button and get no response. All of the people who helped me where more than helpful, not to mention patient with an old guy who is just learning VBA and Ribbon customization procedures. But as they say, you have to start somewhere. Thank you so much everyone, and I though the least I could do is share the procedures.
THIS IS HOW TO REPURPOSE THE ACCESS 2007 HELP ICON BUTTON TO CALL YOUR CUSTOM HELP FILE:
1. Create a standard module (not a class module) and enter the following Declarations:
Option Compare Database
Public Const HH_DISPLAY_TOPIC = &H0
Public Const HH_SET_WIN_TYPE = &H4
Public Const HH_GET_WIN_TYPE = &H5
Public Const HH_GET_WIN_HANDLE = &H6
Public Const HH_DISPLAY_TEXT_POPUP = &HE
Public Const HH_HELP_CONTEXT = &HF
Public Const HH_TP_HELP_CONTEXTMENU = &H10
Public Const HH_TP_HELP_WM_HELP = &H11
Public 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
2. Create a Public Sub in the module with the following parameters, where the Public Sub name is whatever you want it to be, in this case it is CustomHelp; and YourFileName is the name of your custom .chm file (including the path if it is not in the path of your Access file); and the parameters in (control As IRibbonControl, ByRef CancelDefault) must be there:
Public Sub CustomHelp(control As IRibbonControl, ByRef CancelDefault)
Dim hwndHelp As Long
hwndHelp = HtmlHelp(0, "YourFileName.chm", HH_HELP_CONTEXTMENU, 0)
End Sub
3. Create a custom Ribbon or edit a custom Ribbon and enter the following command where CustomHelp is the name of the procedure called:
<commands>
<command idMso="Help" enabled="true" onAction= "=CustomHelp()"/>
</commands>
These procedures will Re-Direct the Access Help question mark button to call your custom file
It does work when you package a file in Runtime
It does NOT affect the VBA widow help button, so you can still use VBA Help
It does not affect pressing F1. To do that, enter your custom help file name in the Help File event on each form and the ContextID if appropriate.
Last edited by LarryE; April 19th, 2009 at 12:11 PM..
Reason: Found the answer
|