shortcut for menu

  • Thread starter Thread starter Douvid
  • Start date Start date
D

Douvid

HI,
in the following code I create a custom menu but I would
like to have the shortcut to be set for the button and
written in the menu. I can't find where to put them ?
Can someone advise, thanks a lot


Dim cbar As Office.CommandBar
Dim monoutil As CommandBarControl
Dim menu1, cbctl1, cbctl2, cbctl3, cbctl4 As
CommandBarControl
Dim sub1, sub2, sub3 As CommandBarButton

'create a control popup on the main Worksheet menu bar
Set monoutil = Application.CommandBars("worksheet menu
bar").Controls.Add(Type:=msoControlPopup)
monoutil.Caption = "&Sbops-Tool 1.0"
monoutil.Visible = True

'add a menu item
Set cbctl1 = monoutil.Controls.Add(Type:=msoControlButton)
With cbctl1
.Visible = True
.Style = msoButtonIconAndCaption
.Caption = "Create an import File" ' is required
for caption
.OnAction = ThisWorkbook.Name & "!
outils.importfile" 'action to perform
.FaceId = 2670
End With
 
Douvid,

I don't think the control's property that shows the shortcut is exposed to VBA.

But you could simply change your caption to include the shortcut:

..Caption = "Create an import File Ctrl-P"

HTH,
Bernie
Excel MVP
 
Back
Top