views:

221

answers:

4

As the title so eloquently put it, I need to know how (or if it's even possible) to bind a macro to a key in Microsoft Word 2007 without recording a new macro each time.

I find myself writing new macros directly in code and then not being able to bind them to a key. Or I might just want to rebind a macro to another key.

+1  A: 

The best solution I've come up with has been to record a new empty macro to the key I want (say, Ctrl+Num . [the Del key on the numpad]) and name the macro ctrl_num_dot. Then I can call any macro from the ctrl_num_dot subroutine.

Andrew Keeton
+2  A: 

Look at the KeysBoundTo collection - see here, the BuildKeyCode method - see here and the list of wdKey constants here

barrowc
+2  A: 

As suggested, look up Word's KeyBindings object in the help file.

Additionally, if your macro must work with international keyboards, this is a very good read:

guillermooo
A: 

Hello! Here is an answer from Microsoft: http://office.microsoft.com/video.aspx?assetid=ES010336334&vwidth=884&vheight=540&CTT=11&Origin=

Essentially,

  1. Click the Office Button.
  2. Select Word Options (near the bottom next to Exit Word).
  3. Select Customize. 4a. If you want to add the macro to a button, select "Macros" from the dropdown under "Choose commands from:". 4b. If you want to add a keybind, click Customize (at the bottom towards the left, next to "Keyboard shortcuts:". Here is the same window as when you create a new macro. Just be sure to click "Assign" after picking the keystroke.
Michael