2012-03-07 60 views
3

以下是錯誤:Excel工作簿Activate事件歧義的C#VSTO

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. 

我可以使用

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

,因爲有一個工作簿沒有無效()方法。有一個Activate()方法,我不想使用它。我想要處理像這樣的工作簿激活事件,但我得到上述錯誤

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

有什麼想法?

回答