这是错误:
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.
Run Code Online (Sandbox Code Playgroud)
我可以用
myWorkbook.Deactivate += new Excel.WorkbookEvents_DeactivateEventHandler(ThisWorkbook_Deactivate);
Run Code Online (Sandbox Code Playgroud)
因为没有工作簿的deactivate()方法.有一个Activate()方法,我不想使用它.我想要像这样处理工作簿激活事件,但我得到上面的错误
myWorkbook.Activate += new Excel.WorkbookEvents_ActivateEventHandler(ThisWorkbook_Activate);
Run Code Online (Sandbox Code Playgroud)
有什么想法吗?
见http://bishoponvsto.wordpress.com/category/vsto/vsto-issues/
"Activate既是Application.Excel的方法又是事件,因此必须将Activate关键字强制转换为事件或方法."