HotKeys Routines

 

The following two functions can be used in Excel, Word and Access to prevent/enable users from using Hotkeys.

 

Sub HotKeysOff()

 

'   Disable Windows Shortcut Keys, for New, Open, Save, Print, Copy, Exit,

Paste,

'   Undo, Redo etc, there are loads of these!!!

    With Application

        .OnKey "^1", ""

        .OnKey "^2", ""

        .OnKey "^3", ""

        .OnKey "^4", ""

        .OnKey "^5", ""

        .OnKey "^6", ""

        .OnKey "^7", ""

        .OnKey "^8", ""

        .OnKey "^9", ""

        .OnKey "^0", ""

        .OnKey "^a", ""

        .OnKey "^b", ""

        .OnKey "^c", ""

        .OnKey "^f", ""

        .OnKey "^g", ""

        .OnKey "^h", ""

        .OnKey "^k", ""

        .OnKey "^n", ""

        .OnKey "^o", ""

        .OnKey "^p", ""

        .OnKey "^s", ""

        .OnKey "^v", ""

        .OnKey "^w", ""

        .OnKey "^x", ""

        .OnKey "^y", ""

        .OnKey "^z", ""

        .OnKey "%{F11}", ""

        .OnKey "+{INSERT}", ""

        .OnKey "^{BREAK}", ""

        .OnKey "^'", ""

        .OnKey "^;", ""

        .OnKey "%'", ""

        .OnKey "%;", ""

        .OnKey "^-", ""

        .OnKey "^/", ""

        .OnKey "^`", ""

    End With

End Sub

 

Sub HotKeysOn()

 

'   Enable the standard windows shortcuts, ^ = CTRL, + = SHIFT, % = ALT

    With Application

        .OnKey "^1"

        .OnKey "^2"

        .OnKey "^3"

        .OnKey "^4"

        .OnKey "^5"

        .OnKey "^6"

        .OnKey "^7"

        .OnKey "^8"

        .OnKey "^9"

        .OnKey "^0"

        .OnKey "^a"

        .OnKey "^b"

        .OnKey "^c"

        .OnKey "^f"

        .OnKey "^g"

        .OnKey "^h"

        .OnKey "^k"

        .OnKey "^n"

        .OnKey "^o"

        .OnKey "^p"

        .OnKey "^s"

        .OnKey "^v"

        .OnKey "^w"

        .OnKey "^x"

        .OnKey "^y"

        .OnKey "^z"

        .OnKey "%{F11}"

        .OnKey "+{INSERT}"

        .OnKey "^'"

        .OnKey "^;"

        .OnKey "%'"

        .OnKey "%;"

        .OnKey "^-"

        .OnKey "^/"

        .OnKey "^`"

    End With

 

End Sub