How to Repurpose/Redirect Access 2007 Help Icon to call custom Hel

L

LarryE

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. The
file name should entered without any other entries, no = sign, no quotes, no
().
 
S

Sky

....
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>
....

You have provided a good summary.

Since you are not using the input arguments (control As IRibbonControl,
ByRef CancelDefault) in your callback procedure, you may wish to specify a
direct function call instead in your onAction without these arguments, as
follows:

Public Function CustomHelp() As Boolean
On Error GoTo ErrExit
HtmlHelp 0, "YourFileName.chm", HH_HELP_CONTEXTMENU, 0
Exit Function
:ErrExit
' do something here
End Sub

<commands>
<command idMso="Help" enabled="true" onAction="=CustomHelp()"/>
</commands>

This above onAction does have the = sign and the ().

The direct function call has the advantage that it is simpler without having
unused arguments, and also it compiles in Access 2003 as well as in Access
2007 if you are maintaining a single compatible source file. (In Access
2003, there is no IRibbonControl class for compiling. And if you try
declaring the control input as a generic Object with late binding, the
ribbon callback is not found in Access 2007.)

And of course, you probably want error handling in the CustomHelp()
procedures.

- Steve
 
S

Sky

....
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.
....

As far as the F1 key, you may also want to repurpose it with an AutoKeys
macro. Otherwise, it may not do what you want when no form or report has the
focus, or if the Help File property is not specified. You can then process
the Screen.ActiveForm or Screen.ActiveControl if you want.

In my experience, Access 2007 has some strange focus issues sometimes, where
I cannot figure out where the focus is. Looking at
Application.CurrentObjectName or Screen.ActiveForm, it may have a value, but
the focus can be somewhere in la-la land between form, navigation pane,
ribbon, or none of these, even after a call to frm.SetFocus.

- Steve
 
L

LarryE

You are right. When I imported the module and UsysRibbon table into another
Access 2007 file to call my help file I got a compile error and a call error
when I clicked the Help button. I changed the Public Sub CustomHelp(control
As IRibbonControl, ByRef CancelDefault) to a Public Function CustomHelp() As
Boolean and it worked. Don't ask me why. The onAction= command worked with
and without the = sign and (). Again, no clue why, but not going to argue.
Just so happy this worked I can't stand it.

Thank you so much for your help and comments. This whole issue has been
interesting. I have found that some of this advanced stuff is pretty well
hidden on the net and in Microsofts forums. You really need to ask the right
question first in the right place. Just finding the correct forum is a
challenge.
 
C

crazyaccessprogrammer

Having used Access since Access 95, I'm often bewildered how little
information is out there relating to the integration of custom help files in
an Access Database. One would have thought that by now there would be a bunch
of books out there on the subject like 'Help Files for Dummies' or somesuch.

And what information is available is scattered in bits and pieces across the
net.

I fear the same scenerio now for the new Office 'Ribbon.' Finding a single
resource to teach you how to create a custom ribbon from the ground up
assuming ZERO knowledge by the user is something I cannot find. And what I do
find about creating custom ribbions is scattered in bits and pieces across
the net... sigh
 
L

LarryE

Well I am not even a programmer. I just am a 60 year old retired guy wo
wanted to learn something new. Well I did learn something new....I should
have stuck to golf!!!
 
S

Sky

LarryE said:
You are right. When I imported the module and UsysRibbon table into
another
Access 2007 file to call my help file I got a compile error and a call
error
when I clicked the Help button. I changed the Public Sub
CustomHelp(control
As IRibbonControl, ByRef CancelDefault) to a Public Function CustomHelp()
As
Boolean and it worked. Don't ask me why. The onAction= command worked with
and without the = sign and (). Again, no clue why, but not going to argue.
Just so happy this worked I can't stand it.

The IRibbonControl argument probably did not compile because you need a
reference to the Microsoft Office 12.0 Object Library, which is necessary
for ribbon callbacks.

Using the simpler function without IRibbonControl avoids this.

However, there are other things that you can do with the ribbon callbacks
that you might want in the future. For example, if you want to modify, hide,
or display ribbons dynamically you do need callback functions with the
library reference.

- Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top