Assigning a macro to the tab key
Article contributed by Bill Coan
Since the TAB key isn't accepted as a legitimate choice in the Customize dialog, use a macro to make the assignment.
Notes
The following macro assigns the tab key to a macro called MacroNameGoesHere. Simply replace
“MacroNameGoesHere” with the name of the macro that you want to run and you'll be
all set, except for the limitations noted afterward.
Code
This code is provided for illustrative purposes only and is not warranted to be suitable for
any particular business purpose. The code may be freely copied for any lawful business purpose.
Sub AssignTabKey()
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyTab), KeyCategory:= _
wdKeyCategoryMacro, Command:="MacroNameGoesHere"
End Sub
Limitation #1
When the cursor is situated in a table cell, the tab key isn't interpreted as a tab key.
Instead, it is interpreted as a NextCell command. If you want to control the action of the tab key
in this situation, you must create a subroutine called NextCell. For example:
Sub NextCell()
'Code listed here will control tab key inside a table cell
End Sub
Limitation #2
When the cursor is situated in a form field in a protected section of a protected document,
the tab key isn't interpreted as a tab key. Instead, it executes a built-in routine that lies
beyond vba's reach.