大鸟的学习乐园
路漫漫其修远兮,吾将上下而求索
posts - 26,comments - 27,trackbacks - 0

 

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

只有注册用户登录后才能发表评论。


网站导航: