View Full Version : Run a macro contained in an add-in using keyboard shorcuts?

06-08-2010, 06:30 PM
Currently the only way I can get a sub named 'insert', which is in contained in an add-in, to run, is to record a macro in the actual workbook which calls the procedure as follows.

Application.Run ("addin_20100608.XLa!Insert")

The actual keyboard shortcut activates a macro in my workbook which then calls the macro I actually want to run. How do I do this more directly so that I press a keyboard shortcut and the macro is run from the add in directly.

Many thanks for any help you can provide,


06-08-2010, 08:56 PM
Hi Jamie,

In the ThisWorkbook module of the addin:

Private Sub Workbook_Open()
'ctrl+shift+right arrow to run macro
Application.OnKey "+^{RIGHT}", "Insert"
End Sub

Here is a list of the keys:

06-09-2010, 07:48 AM

Many thanks for your solution. This is much better than what i was doing previously since it means more of the code can be hidden in the add-in. (I appreciate VBA macros aren't terribly secure but we're making incremental steps). Thanks also for the reference to the other key codes. It's pretty cool to go to bed wondering how to fix a problem, and wake up to a solution provided by a kind stranger. :clap: