Carl479
Carl479

Reputation: 519

Run macro at key press - Space key

I have a Word 2013 Macro which quickly runs a simple spell check dialogue.

I want to run it every time I type a word.

One way of doing this is by running the macro every time I press space.

Therefore, I tried to use the Options>Customize Ribbon>Keyboard Shortcuts method but that did not work for the space key.

How can I run a macro every time press the "space" key?

Thank you in advance.

Upvotes: 1

Views: 6624

Answers (1)

Christina
Christina

Reputation: 1379

You should be able to do this using KeyBindings. I've not tried it with spacebar specifically, but I use this with tab, backspace, etc. The basic idea is:

in a sub that you run at startup or document open:

'This line may differ depending on whether you are running this from a document template or an add-in.
Application.CustomizationContext = ThisDocument.AttachedTemplate
' Create the keybinding.
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeySpacebar), KeyCategory:= _
        wdKeyCategoryMacro, Command:="MyMacro"

Then make sure your macro is named to match whatever you put in Command.

Upvotes: 1

Related Questions