View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Sean Connolly[_3_] Sean Connolly[_3_] is offline
external usenet poster
 
Posts: 25
Default event with commandbar button right-click?

Hi,

Maybe I've got it all wrong. The assumption on my part (that may indeed be
incorrect) is that you want to attach some help to an Office CommandBar
control. *One* way to achieve this is detailed in my earlier post (and
further in the Excel VBA help for the .HelpFile and .HelpContextID properties
- look them up in the VBA Object Browser). This method assumes that the help
that you want to provide your users is a topic in a compiled help file that
has previously been created (e.g. by you).

..HelpContextID is a long integer that simply represents the relevant help
topic that you want displayed when the user presses Shift+F1 when the
relevant Office CommandBar control has the 'focus'. You 'map' (or associate)
the .HelpContextID to actual help topics in your help file creator (WinHelp
or HtmlHelp) and then compile the help file (into a *.hlp or *.chm file
respectively). "What's This" type help pertains to user forms, which I am
again assuming is not relevant to your case. UserForm controls are a
completely separate matter.

AFAIK, I haven't come across an easy way of intercepting the right
mouse-click event of an Office CommandBar control object. (In fact, and again
AFAIK, Office CommandBar controls do not have any exposable events available).

I hope this helps. If I am misunderstanding it badly, then there may be
others in the community that know more or have grasped the nub of your
problem better than I have.

Good Luck. Cheers, Sean.

"RB Smissaert" wrote:

OK, but what I want to do is somehow point to the menu item (not the routine
that is pointed at by the menu item) and then get the help related to that
menu
item. Not sure how your .HelpContextID = 69 in the menu code would fit in
with
this.
One problem is that I can't show a WhatsthisHelp button in my userform as
the title bar has minimize and maximize buttons added by the Windows API.

What I could do, althought it is not that slick is have a checkbox on the
form and
then when this is ticked and you click (left-click) the menu item the help
will popup
and not the normal menu routine.

I will report back when I have a solution for this and I would be interested
if you
have some new ideas.

RBS

"Sean Connolly" .(DoNotSpam) wrote in
message ...
Hi,

Not so sure about right-click, but Office CommandBar controls (2k3) do
have
.HelpFile and .HelpContextId properties that can be set. Look these up in
the
Excel VBA help - where it also says that "Help topics respond to
Shift+F1".

So maybe something like ...

With .Controls.Add(Type:=msoControlButton)
.Caption = "Open report (F3 OR O from the treeview)"
.OnAction = "OpenReport"
.FaceId = 23
.HelpFile = "C:\...\myHelpFile.hlp" ' Full path to your compiled
help
file.
.HelpContextID = 69
' The topic ID number that has been correctly mapped to a topic in your
compiled help file.
End With

Don't know if this also works with HtmlHelp compiled help files (*.chm) or
not - I'm having my own set of problems with text-popup context-sensitive
help (see my other post) from HtmlHelp.

Trust this helps and let me know how you get on.

Cheers, Sean.

"RB Smissaert" wrote:

Would it somehow be possible to trigger an event on right-clicking a
commandbar button?

These buttons are created like this:

Public cb2 As CommandBar

Set cb2 = CommandBars.Add("MyOptionsPopUp", _
msoBarPopup, _
MenuBar:=False, _
temporary:=True)

With cb2
Set FileControl = .Controls.Add(Type:=msoControlPopup)
With FileControl
.Caption = "File"
With .Controls.Add(Type:=msoControlButton)
.Caption = "Open report (F3 OR O from the treeview)"
.OnAction = "OpenReport"
.FaceId = 23
End With

etc.


The purpose is to trigger context sensitive help on the menu.


RBS