none
Need a list of msoControlButton Ids

    Question

  • I found this nice piece of code to create custom shortcuts:

    Sub CreateMyShortcutMenu()
        Dim cmbShortcutMenu As Office.CommandBar
     
        ' Create a shortcut menu named "MyShortcutMenu.
        Set cmbShortcutMenu = CommandBars.Add("MyShortcutMenu", msoBarPopup, False, True)
     
        'Add the cut command
        cmbShortcutMenu.Controls.Add Type:=msoControlButton, Id:=21
     
        ' Add the copy command.
        cmbShortcutMenu.Controls.Add Type:=msoControlButton, Id:=19
     
        ' Add the paste command.
        cmbShortcutMenu.Controls.Add Type:=msoControlButton, Id:=22
     
        ' Add the Sort Ascending command.
        cmbShortcutMenu.Controls.Add Type:=msoControlButton, Id:=210
     
        ' Add the Sort Descending command.
        cmbShortcutMenu.Controls.Add Type:=msoControlButton, Id:=211
     
        ' Add the Filter By Selection command.
        cmbShortcutMenu.Controls.Add Type:=msoControlButton, Id:=640
     
        ' Add the Remove Filter/Sort command.
        cmbShortcutMenu.Controls.Add Type:=msoControlButton, Id:=605
     
        ' Add the Filter Excluding Selection command.
        cmbShortcutMenu.Controls.Add Type:=msoControlButton, Id:=3017
     
        ' Add the Between... command.
        cmbShortcutMenu.Controls.Add Type:=msoControlButton, Id:=10062
     
        Set cmbShortcutMenu = Nothing
     
    End Sub

    It works well but I can't find a good list of all of the available IDs.  Any help would be greatly appreciated.


    MKVermont
    Tuesday, October 04, 2011 2:14 PM

Answers

All replies

    • Proposed as answer by VanderghastModerator Wednesday, October 05, 2011 9:14 AM
    • Marked as answer by MKVermont Wednesday, October 05, 2011 10:29 AM
    Tuesday, October 04, 2011 2:19 PM
  • Thank you very much for responding so quickly.  Your answer was just what I needed.

    Do you know the best way to remove or modify the newly created shorcut?

     


    MKVermont
    Tuesday, October 04, 2011 6:35 PM
  • From this MSDN article:

    http://msdn.microsoft.com/en-us/library/ff194247.aspx

    Once you've run the code, the shortcut menu is saved as part of the database. You don't have to run the same code to re-create the shortcut menu every time that you open the database.

    To assign the shortcut menu to a form, form control, or report, set the Shortcut Menu property of the object to Yes and set the Shortcut Menu Bar property of the object to the name of the shortcut menu. For this example, set the Shortcut Menu Bar property to MyShortcutMenu.

     

    Hope this helps,


    Daniel van den Berg | Washington, USA | "Anticipate the difficult by managing the easy"
    • Marked as answer by MKVermont Wednesday, October 05, 2011 2:00 PM
    Wednesday, October 05, 2011 1:07 AM
  • If you use this in a Parent form will it be applicable for the subform or do you have to attach it to the subform as well?
    MKVermont
    Wednesday, October 05, 2011 2:02 PM
  • I found this nice piece of code to create custom shortcuts:

    Sub CreateMyShortcutMenu()
        Dim cmbShortcutMenu As Office.CommandBar
        ' Create a shortcut menu named "MyShortcutMenu.
        Set cmbShortcutMenu = CommandBars.Add("MyShortcutMenu", msoBarPopup, False, True)
        'Add the cut command
        cmbShortcutMenu.Controls.Add Type:=msoControlButton, Id:=21
        ' Add the copy command.
        cmbShortcutMenu.Controls.Add Type:=msoControlButton, Id:=19
        ' Add the paste command.
        cmbShortcutMenu.Controls.Add Type:=msoControlButton, Id:=22
        ' Add the Sort Ascending command.
        cmbShortcutMenu.Controls.Add Type:=msoControlButton, Id:=210
        ' Add the Sort Descending command.
        cmbShortcutMenu.Controls.Add Type:=msoControlButton, Id:=211
        ' Add the Filter By Selection command.
        cmbShortcutMenu.Controls.Add Type:=msoControlButton, Id:=640
        ' Add the Remove Filter/Sort command.
        cmbShortcutMenu.Controls.Add Type:=msoControlButton, Id:=605
        ' Add the Filter Excluding Selection command.
        cmbShortcutMenu.Controls.Add Type:=msoControlButton, Id:=3017
        ' Add the Between... command.
        cmbShortcutMenu.Controls.Add Type:=msoControlButton, Id:=10062
        Set cmbShortcutMenu = Nothing
    End Sub

    It works well but I can't find a good list of all of the available IDs.  Any help would be greatly appreciated.


    MKVermont
    MKVermont wrote the above and It sounds like it might be just what I need.  I have not yet downloaded the lists of ID's but that will be next if I can get it to work.  Do I put this code in a module and then call the "CreateMyShortcutMenu" procedure from a command button?  How do I "run the code"?  I tried putting it in a module, but when I debug it, it doesn't like the " Dim cmbShortcutMenu As Office.CommandBar" line.  Any help for a rookie would be welcome!
    Wednesday, May 16, 2012 10:12 PM