Key bindings for commandbar pop-ups?

B

Benjamino5

My template has a commandbar with buttons and pop-ups (menus). I've been
adding keybindings for the buttons by simply having the shortcut key call the
same macro the button calls.

Now, I'd like to add a keybinding that will open a pop-up (menu) on the
commandbar, just like pressing Alt-F opens the File menu in Word.

The desired behavior would be pressing Alt-something and having a pop-up on
my commandbar open, so that the user could use the arrow keys to go up and
down the menu. Pressing Enter would then select a command--all exactly like
the regular menus in Word.

Here's what I've been doing to assign keys to macros so far:

____________________

' first I set the CustomizationContext to my template, etc. then I do this:
With Application.KeyBindings
' "New Solution" is Alt-N
.Add KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyN), _
KeyCategory:=wdKeyCategoryMacro, Command:="Nl1"
' etc.

_______________________

It seems like I could somehow put the pop-up into the Command argument--or
do I need to change the KeyCategory to wdKeyCategoryCommand as well?

Is this even possible?

Thanks in advance!

Ben
 
J

Jonathan West

Hi ben,

You're heading off into the wrong direction here. You can achieve what you
want, but the means by which you go about it is completely different from
what you were trying.

Suppose you have a toolbar button whose caption is "FixThis", and you want
an Alt-F to reach that button.

To do this, customize the button and type "&FixThis" into the caption.

when you close the Customize dialog, you will now find that the caption
still says "FixThis", but the F is now underlined. That means that the F is
an accelerator key.

Now if you press Alt, and then F repeatedly, you will cycle between the
various items on the menu and any other toolbars that have the F accelerator
key, in this case, between the File menu and your FixThis button.

If you choose an accelerator key that happens not to be used on the main
menu bar, then pressing Alt and then the letter will take you straight to
your button.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
B

Benjamino5

Jonathan,

Thank you! I had no idea that was how it was done. This is terrific; my
authors will be pleased that they can use keyboard shortcuts for everything.

Ben
 

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