|
楼主 |
发表于 2013-7-19 11:15
|
显示全部楼层
hwc2ycy 发表于 2013-7-19 11:10
Dim WithEvents mn1 As Office.CommandBarButton
Dim WithEvents mn2 As Office.CommandBarButton
...
我也不知道怎么回事了。这是VB里面的原代码,你帮我弄一个吧。谢谢了。
Dim oXL As Object
Dim mnMain As Office.CommandBarPopup
Dim WithEvents mn1 As Office.CommandBarButton
Dim WithEvents mn2 As Office.CommandBarButton
Dim WithEvents MyButton As Office.CommandBarButton
Private Sub AddinInstance_OnConnection(ByVal Application As Object, ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As Object, custom() As Variant)
' Dim mymenu As Object 'CommandBarControl
' Dim mnMain As Object
' Dim mn1 As Object, mn2 As Object
On Error Resume Next
Set oXL = Application
oXL.CommandBars("Worksheet Menu Bar").Controls("提取功能").Delete
Set mnMain = oXL.CommandBars("Worksheet Menu Bar").Controls.Add(Type:=msoControlPopup, Before:=11)
mnMain.Caption = "提取功能"
Set mn1 = mnMain.Controls.Add(Type:=msoControlButton, Before:=1)
With mn1
.Caption = "提取文件名"
.OnAction = "!<" & AddInInst.ProgId & ">"
.FaceId = 162
'.Visible = True
End With
Set mn2 = mnMain.Controls.Add(Type:=msoControlButton, Before:=2)
With mn2
.Caption = "提取E表数据"
.BeginGroup = True '增加间隔符
.OnAction = "!<" & AddInInst.ProgId & ">"
.FaceId = 300
'.Visible = True
With .Controls.Add(Type:=msoControlButton)
.Caption = "子菜单一"
.Visible = True
End With
With .Controls.Add(Type:=msoControlButton)
.Caption = "子菜单二"
.Visible = True
End With
End With
End Sub
|
|