0
我試圖如何在Microsoft.Office.Interop.Word命名空間中設置事件?
var wordApp = new Microsoft.Office.Interop.Word.Application();
var doc = wordApp.Documents.Open(FileName);
wordApp.Visible = true;
((Microsoft.Office.Interop.Word.ApplicationEvents4_Event)wordApp.Quit) += new ApplicationEvents4_QuitEventHandler(delegate
{
MessageBox.Show("word closed!");
});
,但我得到:
Cannot convert method group 'Quit' to non-delegate type 'Microsoft.Office.Interop.Word.ApplicationEvents4_Event'. Did you intend to invoke the method?
Microsoft.Office.Interop.Word._Application.Quit(ref object, ref object, ref object)'
and non-method 'Microsoft.Office.Interop.Word.ApplicationEvents4_Event.Quit'. Using method group.
我沒有因爲警告的演員,但沒有解決。我不知道如何解決這個錯誤。提前致謝。
謝謝!你已經救了我的一天。祝你有個愉快的一天。 – Jack