Question

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.

Was it helpful?

Solution

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

OTHER TIPS

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:

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top