Word Add-In Keybinding

B

Bill E.

I'm working on a Word Add-In written in VB 6.0. My
question is. If you want to assign a keybinding (like you
would to a macro in VBA) how would you do that from the
add-in? What would the "command:=" syntax be?

Any help would be appreciated.
 
D

dz

Is this a "permanent" binding to the same macro? If so,
I've always just done this in the add-in template itself.
Retrieve the template, then when you assign the keybinding
through customize, make sure it states your template in
the "save changes in" drop down box.
 
D

dz

Since I don't know anything about your dll, try the VBA
help for KeyBindings - here is the first part of the help
text. You can change the customization content to point
to the active template also with Active
Document.ActiveTemplate:

Returns a KeyBindings collection that represents
customized key assignments, which include a key code, a
key category, and a command.

expression.KeyBindings

expression Required. An expression that returns one of
the objects in the Applies To list.

Example
This example assigns the CTRL+ALT+W key combination to the
FileClose command. This keyboard customization is saved in
the Normal template.

CustomizationContext = NormalTemplate
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyControl,
wdKeyAlt, _
wdKeyW), KeyCategory:=wdKeyCategoryCommand, _
Command:="FileClose"
 

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