从几天我就与BeforeClose事件打架。问题是我打开更多文档的时候。例如: 我开了4页新的文件,在新建文档事件武官BeforeClose事件的每一个文档到文档这样的:C#单词AddIn BeforeClose事件消失
var vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
vstoDoc.BeforeClose += new System.ComponentModel.CancelEventHandler(ThisDocument_BeforeClose);
现在我试图关闭它,所以我以后文档2关闭文档4和现在是问题,因为Doc1仍然有BeforeClose事件,但Doc3没有。所以,如果我从上次开始关闭文件降序,它工作正常。但是,如果我关闭例如Doc1作为第一个其余没有BeforeClose事件。我不知道发生了什么事。
this.Application.DocumentBeforeClose + = new Word.ApplicationEvents4_DocumentBeforeCloseEventHandler(ApplicationDocumentBeforeClose); 解决这一切 –