How to change Control-Y behavior in Excel-VBA's IDE

Excel VBA's IDE registers a Control-y as "cut this line of code".

By contrast, redo-ing is accomplished by Alt-e, R.

Is there any way to change this behavior and make Control-y be the much more common redo?

(For more on the default behavior, here is a link: http://www.pcreview.co.uk/threads/ctrl-y-in-vba-ide.2198613/)


This autohotkey script I wrote seems to work:

#IfWinActive ahk_class wndclass_desked_gsk

^y::
Send {escape}
Send !e;
Send r
Send {escape}
Send {escape}
return

#IfWinActive

In response to the question of :

I am wondering if the VBE can be directly programmed to solve this problem?

The answer unfortunately is negative. The only way to modify the behavior is by using add-ins whose capabilities are summed up by Microsoft as :

  • A startup module to trap the opening and closing of the add-in.
  • Some code to add our menu items to the commandbars on opening and remove them when closing
  • For the VBE, a class mosule to handle the menu items "Click" events
  • Some code to perform your menu's actions.

Specifically, intercepting hotkeys is not in the list.

The answer by Eliyahu is then still correct, and AutoHotKey (or AutoIt) is still the only solution.