If you are going to deploy your COM Add-In to users running Excel 2007, see COM Add-Ins In Excel 2007 for information about using CAIs in Excel 2007.
Getting Started First, create a new folder such as Your project should now have the following references.
Other references are not required for a basic COM Add-In, but may be necessary by your code. Your version number will be different if you are using a different version of Office or Excel.
module, insert the following code: Public XL As Excel. Application Public Excel Events As CExcel Events Public Power Point Events As CPower Point Events Public This CAI As Office.
COMAdd In Public Const C_EXCEL_TOOLS_MENU_ID As Long = 30007 Public Const C_POWERPOINT_TOOLS_MENU_ID As Long = 30007 Now we turn our attention to the Private With Events p Menu Item1 As Office. Add( _ Type:=mso Control Button, temporary:=True) With p Menu Item1 . Caption = "Click Me Excel" End With p Controls Coll.
Creating A COM Add In This page describes how to write a COM Add In With Visual Basic 6.
Introduction Beginning in verison 2000, Office programs such as Excel and Power Point began support for a new type of add in component called a COM Add In.A COM Add IN (CAI) is completely different from and independent from standard XLA type add-ins.A CAI has several advantages over a conventional XLA or PPA (Power Point) add in.Command Bar Button Private Sub Class_Initialize() Set p Controls Coll = New Collection Set XLApp = mod Globals. Add p Menu Item1 End Sub Private Sub p Menu Item1_Click(By Val Ctrl As Office.XL Setup Controls End Sub Private Sub Class_Terminate() Set p Menu Item1 = XLApp. Command Bar Button, Cancel Default As Boolean) Msg Box "Menu Item Click From Excel COM Add In" End Sub Private Sub XLApp_New Workbook(By Val Wb As Excel.Workbook) Msg Box "New Workbook From Add In: " & Wb.