Excel workbook activates event ambiguity for C # VSTO

Here is the error:

Error   2   Cannot assign to 'Activate' because it is a 'method group'  
Warning 1   Ambiguity between method 'Microsoft.Office.Interop.Excel._Workbook.Activate()' and non-method 'Microsoft.Office.Interop.Excel.WorkbookEvents_Event.Activate'. Using method group.

      

I can use

myWorkbook.Deactivate += new Excel.WorkbookEvents_DeactivateEventHandler(ThisWorkbook_Deactivate);

      

because there is no deactivation () method for the book. There is an Activate () method that I DO NOT want to use. I want to handle the book Activate an event like this but I am getting the error above

myWorkbook.Activate += new Excel.WorkbookEvents_ActivateEventHandler(ThisWorkbook_Activate);

      

Any thoughts?

+3


source to share


1 answer


See here http://bishoponvsto.wordpress.com/category/vsto/vsto-issues/



"Activate is both a method and an Application.Excel event, so the Activate keyword must be passed to either the event or the method."

+8


source







All Articles