+ Reply to Thread
Results 1 to 12 of 12

Adding shortcut keys to Custom menus

  1. #1
    Registered User
    Join Date
    08-17-2010
    Location
    Bangalore
    MS-Off Ver
    Excel 2003
    Posts
    19

    Adding shortcut keys to Custom menus

    Hi,

    I want help to add shortcut keys to all the custom menus/sub-menus in tool
    o For example, for the “Juniper Tool 1B” menu item, use “J” as the shortcut key.
    It's urgent, Can someone please help. I am relatively new to Excel programming.

  2. #2
    Registered User
    Join Date
    01-20-2010
    Location
    Dusseldorf, Germany
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Adding shortcut keys to Custom menus

    Hi, you can do it using the & sign before the letter you want to use as shortcut:

    Please Login or Register  to view this content.
    This will generate the Menu name with A as shortcut.
    Visit the Advanced Features Add-In for MS 2003 Official Website or if you're looking for VBA help you can just surf the VBA Handbook

  3. #3
    Registered User
    Join Date
    08-17-2010
    Location
    Bangalore
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: Adding shortcut keys to Custom menus

    I have the code like this:
    Please Login or Register  to view this content.
    So, I add this line, after the Call CreateMenu?
    Last edited by romperstomper; 08-17-2010 at 04:25 AM.

  4. #4
    Registered User
    Join Date
    04-16-2009
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    29

    Re: Adding shortcut keys to Custom menus

    Hi Gayathri,

    At run time you need to add this line of code. The object name for the sub menu (the one which is going to be customized) will be set at run time.

    Regards,
    Ram

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

    Re: Adding shortcut keys to Custom menus

    You need to alter your CreateMenu subroutine to change the captions it uses.
    Everyone who confuses correlation and causation ends up dead.

  6. #6
    Registered User
    Join Date
    08-17-2010
    Location
    Bangalore
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: Adding shortcut keys to Custom menus

    I see that there is a line which says MenuObject.Caption = Caption, based on the value passed on to the MenuObject. Now, if I want to underline the first letter of each of the value passed to Caption, how to I do that with the & symbol?

  7. #7
    Registered User
    Join Date
    08-17-2010
    Location
    Bangalore
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: Adding shortcut keys to Custom menus

    This is what I have presently

    Please Login or Register  to view this content.
    Last edited by romperstomper; 08-17-2010 at 04:41 AM. Reason: add code tags

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

    Re: Adding shortcut keys to Custom menus

    Use:
    Please Login or Register  to view this content.
    and:
    Please Login or Register  to view this content.
    Note: you must use code tags when posting code, as specified in the forum rules. I have added them for you on this occasion but you must do it in future.

  9. #9
    Registered User
    Join Date
    08-17-2010
    Location
    Bangalore
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: Adding shortcut keys to Custom menus

    I apologize. Henceforth, I shall add them in future.
    Thanks for your response. Just a question to improve my understanding. If the first letter had to be chosen as shortcut key, an & was used before the Caption. If any other letter has to be "shortkeyed" then, how is that achieved?

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

    Re: Adding shortcut keys to Custom menus

    Well, the simplest way would be to leave the code as it was originally and add the & signs to the cells containing the captions. Otherwise you would have to parse the caption strings to work out where to put the & sign.

  11. #11
    Registered User
    Join Date
    08-17-2010
    Location
    Bangalore
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: Adding shortcut keys to Custom menus

    Thank you very much, and is there a way I can add short cut keys to buttons on the sheet also?

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

    Re: Adding shortcut keys to Custom menus

    If you are using buttons from the control toolbox, then set the Accelerator property to the letter you want. If you are using Forms controls, then you can assign a shortcut key via the macros dialog to the macro that is attached to the button. (even though the Button object has an Accelerator property, I don't know of any way to set it).

+ 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