Private Sub Workbook_Open()
Dim cbr As CommandBar
Dim ctrMenu As CommandBarControl
Dim ctr As CommandBarControl
Set cbr = Application.CommandBars("Worksheet Menu Bar")
For Each ctr In cbr.Controls
If ctr.Caption = "custom" Then
Exit Sub
End If
Next
Set ctlMenu = cbr.Controls.Add(Type:=msoControlPopup)
With ctlMenu
.Caption = "custom"
With .Controls.Add(Type:=msoControlButton)
.Caption = "aa"
.OnAction = "action1"
End With
With .Controls.Add(Type:=msoControlButton)
.Caption = "bb"
.OnAction = "action2"
End With
End With
End Sub
posted on 2009-08-13 15:25
大鸟 阅读(228)
评论(0) 编辑 收藏 所属分类:
VBA