Excel Workbook Activate Event Ambiguity for C# VSTO

北城余情 提交于 2019-12-23 21:08:31

问题


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 deactivate() method for a workbook. There is a Activate() method, which i DO NOT want to use. I'm wanting to handle the workbook Activate event like this, but i get the error above

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

Any thoughts?


回答1:


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

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



来源:https://stackoverflow.com/questions/9610285/excel-workbook-activate-event-ambiguity-for-c-sharp-vsto

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!