define class SesAddin as Session olepublic oCommandbutton = .NULL. oApplication = .NULL. IMPLEMENTS _CommandBarButtonEvents IN {2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}#2.1 procedure SetupAddin With THIS local loMSProj as MSProject.Application loMSProj = getobject(,'msproject.application') if type('.oApplication') <> 'O' then .oApplication = loMSProj endif if vartype(loMSProj) = 'O' then if type([loMSProj.CommandBars.Item("Standard").Controls.Item('Load Project')]) = 'O' then .oCommandbutton = loMSProj.CommandBars.Item("Standard").Controls.Item('Load Project') else .oCommandbutton = loMSProj.CommandBars.Item("Standard").Controls.Add(1) With .oCommandbutton .Caption = 'Load Project' .Style = msoButtonCaption .Tag = 'Some Info' .OnAction = "MyTest" .Visible = .T. Endwith endif =eventhandler(.oCommandbutton,THIS) endif Endwith endproc procedure ResetAddin With THIS .oApplication.CommandBars.Item("Standard").Controls.Item("Load Project").Delete() .oCommandbutton = .NULL. .oApplication = .NULL. Endwith endproc procedure Error LPARAMETERS nError, cMethod, nLine local lcerrorstr set textmerge on text to lcerrorstr noshow Error: <<transform(nError)>> Method: <<cMethod>> Message: <<message())>> Line No: <<transform(nLine)>> Variable: <<transform(sys(2018))>> Time: <<transform(datetime())>> endtext lcerrorstr = lcerrorstr + replicate(chr(13)+chr(10),2) if file('c:\temp\AddinError.log') then strtofile(lcerrorstr,'c:\temp\AddinError.log',1) else strtofile(lcerrorstr,'c:\temp\AddinError.log',0) endif endproc procedure Release release THIS endproc procedure _CommandBarButtonEvents_Click(Ctrl AS Office.CommandBarButton, CancelDefault AS LOGICAL @) AS VOID declare integer MessageBox in user32 as WinMessage integer, string, string, integer WinMessage(0,Ctrl.Caption,'Message',MB_OK) endproc enddefineYou can create multiple instances of this class with different code in the Setup method or you could create one instance that had many different Setup methods for each button. All the buttons would be bound to the the same object (THIS) and you could differentiate between what button was clicked by querying the Caption or Tag or any other property of the control. Ctrl is an object reference to the one that was clicked.