excel - Disable key or key combination -


how disable key combination or characters office 2010.

i tried following code did not work.

sub disable_keys()     dim keysarray variant     dim key variant      keysarray = array("@", "!", "~", "%", "shift+f12")      'disable startkeycombination key(s) every key in keysarray     each key in keysarray         application.onkey key, "mymsg"     next key end sub 

private sub workbook_open()   '// disable accelerators keys in excel 2007-2013     dim ctl commandbarcontrol         each ctl in application.commandbars("&legacy keyboard support").controls             ctl.tag = ctl.caption             ctl.caption = replace(ctl.caption, "&", "")         next     dim startkeycombination variant     dim keysarray variant     dim key variant     dim long     on error resume next         '// shift key = "+"  (plus sign)         '// ctrl key = "^"   (caret)         '// alt key = "%"    (percent sign         '// fill array keys , key combinations         '// shift-ctrl, shift- alt, ctrl-alt, shift-ctrl-alt         each startkeycombination in array("+", "^", "%", "+^", "+%", "^%", "+^%")             keysarray = array("{bs}", "{break}", "{capslock}", "{clear}", "{del}", _                               "{down}", "{end}", "{enter}", "~", "{esc}", "{help}", "{home}", _                               "{insert}", "{left}", "{numlock}", "{pgdn}", "{pgup}", _                               "{return}", "{right}", "{scrolllock}", "{tab}", "{up}")          '// disable startkeycombination          each key in keysarray              application.onkey startkeycombination & key, ""          next key          '// disable startkeycombination key(s) every other key          = 0 255              application.onkey startkeycombination & chr$(i), ""          next          '// disable f1 - f15 keys in combination shift, ctrl or alt key          = 1 15              application.onkey startkeycombination & "{f" & & "}", ""          next      next startkeycombination      '// disable f1 - f15 keys      = 1 15          application.onkey "{f" & & "}", ""      next      '// disable pgdn , pgup keys      application.onkey "{pgdn}", ""      application.onkey "{pgup}", ""  end sub 

reference below links

excel automation

systemparametersinfo function


Comments