Tuesday, December 22, 2009

How to disable user from using short-cut keys using VBA

You can disable the keybinding using the following code

Sub VBA_DisableKey()

'This code will disables Ctrl + O FileOpen command.
' Disable Ctrl + O

FindKey(BuildKeyCode(wdKeyControl, wdKeyO)).Disable

' Rebind Ctrl + O to FileOpen

FindKey(BuildKeyCode(wdKeyControl, wdKeyO)).Rebind wdKeyCategoryCommand, "FileOpen"

End Sub

Use the rebind method to restore the bind.

No comments: