+ Reply to Thread
Results 1 to 6 of 6

Adding Hotkey to Macro with Code?

Hybrid View

Neg0r Adding Hotkey to Macro with... 12-06-2010, 11:24 AM
snb Re: Adding Hotkey to Macro... 12-06-2010, 11:49 AM
Neg0r Re: Adding Hotkey to Macro... 12-06-2010, 12:06 PM
Neg0r Re: Adding Hotkey to Macro... 12-06-2010, 07:01 PM
s970022 Macro cannot be found error 01-12-2011, 07:35 AM
romperstomper Re: Adding Hotkey to Macro... 01-12-2011, 07:42 AM
  1. #1
    Registered User
    Join Date
    12-06-2010
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    5

    Adding Hotkey to Macro with Code?

    Hello again
    I have another problem.
    I have a macro that creates excel-files and it also adds a small amount of VBA-code to those new files (just a simple subroutine that opens a subroutine of an addin).
    Now it would be helpful, when this subroutine would have an automatically assigned hotkey.

    So my question:
    Is there any workaround to place a macro with VBA in a new workbook that has automatically assigned a hotkey to it?

    I guess not :] - but if you have any ideas how to do that: bring it on! :D

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Adding Hotkey to Macro with Code?

    Not a workaround (around what ?), just normal code.



  3. #3
    Registered User
    Join Date
    12-06-2010
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Adding Hotkey to Macro with Code?

    Ok, and how does this code look like?
    Somehow like that?
    With Application
    .OnKey Key:="Shift+K", Procedure:="test"
    ...but where do I have to place that then ? - Somewhere in the OpenWorkbook Method?

    edit:
    ok, when I do that:
    Private Sub Workbook_Open()
    Application.OnKey "+^{m}", "test"
    End Sub
    it seems to work!!

    But how do I write this Code automatically with VBA in the openworkbook method? I only managed to write code in a code modul :/
    Last edited by Leith Ross; 12-06-2010 at 12:46 PM. Reason: Added Cpde Tags

  4. #4
    Registered User
    Join Date
    12-06-2010
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Adding Hotkey to Macro with Code?

    Ok, I managed it . Thanks anyway
    Last edited by Neg0r; 12-06-2010 at 07:07 PM.

  5. #5
    Registered User
    Join Date
    01-10-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2003
    Posts
    4

    Macro cannot be found error

    I am writing a test code in ThisWorkbook module

    Sub Workbook_Open()
    Application.OnKey "{m}", "test"
    End Sub

    Sub test()
    MsgBox "Done"
    End Sub

    However when I reopen the file again and click the "m" button, it prompted up an error message that "The Macro "D:\Mymacro.xls'!test' can not be found.". But the procedure is just underneath. What's going on?
    I checked the Security level is set to low. Everything seems in the proper settings.

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,016

    Re: Adding Hotkey to Macro with Code?

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread.
    Everyone who confuses correlation and causation ends up dead.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1