vb中封装自定义二级菜单
我在vb6中想给工作簿增加一个 自定义二级菜单代码如下怎么不行呢?代码封装成dll求高人指点Private JXMBAR As Object
Private shiyan As Object
Private WithEvents shiyan1 As Office.CommandBarButton
Private WithEvents shiyan11 As Office.CommandBarButton
Public Sub 自定义菜单() '自定义菜单
On Error Resume Next
Set xlapp = GetObject(, "Excel.Application")
Dim JXMBAR As Office.CommandBar
If xlapp Is Nothing Then
MsgBox "获取Application对象出错!"
Else
For Each JXMBAR In xlapp.CommandBars
If JXMBAR.Name = "我的工具" Then xlapp.CommandBars("我的工具").Delete
Next
xlapp.CommandBars.Add(Name:="我的工具").Visible = True
xlapp.CommandBars("我的工具").Position = msoBarTop
Set shiyan = xlapp.CommandBars("我的工具").Controls.Add(Type:=msoControlPopup)
With shiyan
.Caption = "试验按钮"
.Style = msoButtonIconAndCaption
Set shiyan1 = shiyan.Controls.Add(Type:=msoControlPopup)
With shiyan1
.Caption = "月份合计"
.Style = msoButtonIconAndCaption
Set shiyan11 = shiyan1.Controls.Add(Type:=msoControlButton)
With shiyan11
.Caption = "一月份"
.FaceId = 263
.Style = msoButtonIconAndCaption
End With
End With
End With
End Sub
补充:VB , VBA