Sure. Here it is.
Connectexcel class module :
'FROM
'
http://www.cpearson.com/Excel/CreatingCOMAddIn.aspx
'REFERANCES REQUIRED FOR THIS ADDIN
'C:\Program Files\Common Files\microsoft shared\OFFICE11\MSO.DLL
'C:\Program Files\Office2003\OFFICE11\EXCEL.EXE
'C:\Program Files\Common Files\Designer\MSADDNDR.DLL
Option Explicit
Implements AddInDesignerObjects.IDTExtensibility2
Private Sub IDTExtensibility2_OnAddInsUpdate(custom() As Variant)
' not used but required by Implements.
End Sub
Private Sub IDTExtensibility2_OnBeginShutdown(custom() As Variant)
' not used but required by Implements.
End Sub
Private Sub IDTExtensibility2_OnConnection(ByVal Application As
Object, _
ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _
ByVal AddInInst As Object, custom() As Variant)
''''''''''''''''''''''''''''''
' Called automaticaly when Excel loads the CAI.
''''''''''''''''''''''''''''''
Set XL = Application
Set ThisCAI = AddInInst
Set ExcelEvents = New CExcelEvents
End Sub
Private Sub IDTExtensibility2_OnDisconnection(ByVal RemoveMode As
AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)
''''''''''''''''''''''''''''''
' Called automaticaly when Excel unloads the CAI.
''''''''''''''''''''''''''''''
Set XL = Nothing
Set ThisCAI = Nothing
Set ExcelEvents = Nothing
End Sub
Private Sub IDTExtensibility2_OnStartupComplete(custom() As Variant)
' not used but required by Implements.
End Sub
In Cexcelevents class module ;
Private Sub SetupControls()
''''''''''''''''''''''''''''''''''''''''''''''''''''
' Setup one control. Repeat this code for all other
' user interface elements.
''''''''''''''''''''''''''''''''''''''''''''''''''''
'Set pMenuItem1 = XLApp.CommandBars("CELL").Controls.Add( _
' Type:=msoControlButton, Temporary:=True)
With XLApp.CommandBars("Cell").Controls.Add
With .Add(Temporary:=True)
'With pMenuItem1
.Caption = "excel GSM"
.OnAction = "excel GSM"
.Tag = excelGSM
'.BeginGroup = True
End With
End With
pControlsColl.Add pMenuItem1
End Sub
Private Sub pMenuItem1_Click(ByVal Ctrl As Office.CommandBarButton,
CancelDefault As Boolean)
MsgBox "Menu Item Click From Excel COM Add In"
End Sub- Hide quoted text -
- Show quoted text -