Results 1 to 15 of 15
  1. #1
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Assign a shortcut key to a custom menu command

    Hi,
    Is it possible to add a shortcut key reference into the menus for a custom menu item I added. I want my macro shortcut key which is CTRL+SHIFT+Z to display next to the menu item in the menus.
    Can this be done?
    Tx
    Regards,
    Rudi

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Assign a shortcut key to a custom menu command

    You can just add the text right at the end of the "name" (you many need to add some spaces to move it to the right)

    Steve

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Assign a shortcut key to a custom menu command

    As far as I know, you can only do this in VBA:

    CommandBars("Tools").Controls("My Item").ShortcutText = "Ctrl+Shift+Z"

  4. #4
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Assign a shortcut key to a custom menu command

    <img src=/S/rofl.gif border=0 alt=rofl width=15 height=15> Is that it!!!????

    <img src=/w3timages/censored.gif alt=censored border=0> - so why didn't I think of that????
    Regards,
    Rudi

  5. #5
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Assign a shortcut key to a custom menu command

    Aha! So there is another way!

    Question:
    Is one better than the other? Are there advantages to using the VBA method!

    I'll have to experiment to see the pro's and con's of each!

    Tx guys
    Regards,
    Rudi

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Assign a shortcut key to a custom menu command

    Modifying the caption has the advantage of being easy.
    Setting the ShortcutText property has the advantage that the text will always be displayed in the correct position, regardless of the width of the menu.
    Note: you don't actually have to write a macro to set ShortcutText, you can type the instruction in the Immediate window.

  7. #7
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Assign a shortcut key to a custom menu command

    In addition to what Hans lists as pros and cons, modifying the caption will also display it in the Tool tip if you have a button and no text. Whether this is a pro or con, I guess depends on what you want...

    Steve

  8. #8
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Assign a shortcut key to a custom menu command

    Cheers guys...I knew I could count on your comments.
    Tx
    Regards,
    Rudi

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Assign a shortcut key to a custom menu command

    If you display screentips on toolbars (this is a setting in the Options tab of Tools | Customize), the ShortcutText property will be displayed in a toolbar button's tool tip.

  10. #10
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Assign a shortcut key to a custom menu command

    <img src=/S/confused.gif border=0 alt=confused width=15 height=20>Perhaps I am missing something, but checking the "Show screentips on toolbars" from Tools | Customize - Options(tab), seems to toggle the display of the caption and is unrelated to the "ShortcutText"...

    Steve

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Assign a shortcut key to a custom menu command

    Sorry, my error. I meant the check box 'Show shortcut keys in screentips'. I don;t know if this is available in all versions of Excel/Office.

  12. #12
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Assign a shortcut key to a custom menu command

    That option is not there in XL2002 SP3.

    [I believe, even on my "slow days", if it were, I could have figured it out, even with your mistake in the directions... <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    Steve

  13. #13
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Assign a shortcut key to a custom menu command

    It's me who is having a slow day. That option is available in Access, Outlook, PowerPoint, Publisher and Word, but not in Excel! <img src=/S/blush.gif border=0 alt=blush width=15 height=15> <img src=/S/blush.gif border=0 alt=blush width=15 height=15>

    This is an Office-wide setting, so if you turn it on in, for example Word, it will be on in Excel too (no need to restart Excel), and if tooltips are displayed, they will show the ShortcutText too.
    If you wish, you can turn it on in Excel using VBA:

    Application.CommandBars.DisplayKeysInTooltips = True

    Sorry for the confusion!

  14. #14
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Assign a shortcut key to a custom menu command

    It is odd that it is not available in excel....

    Steve

  15. #15
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Assign a shortcut key to a custom menu command

    Well i'm glad this is resolved...I was starting to get confused the longer the thread become... <img src=/S/wink.gif border=0 alt=wink width=15 height=15> <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    Now the thread is useful across a wide range of versions...
    Regards,
    Rudi

Posting Permissions

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