Consulting

Results 1 to 3 of 3

Thread: Run a macro contained in an add-in using keyboard shorcuts?

  1. #1

    Run a macro contained in an add-in using keyboard shorcuts?

    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,

    Jamie

  2. #2
    VBAX Regular Danny's Avatar
    Joined
    Mar 2009
    Posts
    49
    Location
    Hi Jamie,

    In the ThisWorkbook module of the addin:

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

    Here is a list of the keys:
    http://msdn.microsoft.com/en-us/libr...ffice.11).aspx
    I not only use all the brains that I have, but all that I can borrow.

  3. #3
    Danny,

    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.

    Jamie

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •