Option Explicit
Public xlApp As Excel.Application
Private Sub AddinInstance_OnConnection(ByVal Application As Object, ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As Object, custom() As Variant)
Set xlApp = Application
CreateToolbarButtons
End Sub
Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode As AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)
Set xlApp = Nothing
End Sub
Public Sub CreateToolbarButtons()
Dim cbBar As
Dim btNew As
On Error Resume Next
("cell").Reset
Set cbBar = ("cell").Controls.Add(msoControlPopup, Before:=1)
cbBar.Caption = "调试"
Set btNew = cbBar.Controls.Add(1, 2)
With btNew
.Caption = "调试"
.OnAction = "test1"
End With
End Sub
Sub test1()
MsgBox "你成功了!"
End Sub