|
以下是添加菜单按钮的代码,如何在mn2.Caption = "提取E表数据" 下 添加二级子菜单。
另请帮忙给注释一下红色代码部分。谢谢了。
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
End With
End Sub
|
|