【发布时间】:2017-02-11 13:00:17
【问题描述】:
我有一个 Word 插件 (VSTO),它将在用户关闭 Word 文档后对其进行处理。
不幸的是,即使在文档不会真正关闭的情况下,也会引发 DocumentBeforeClose 事件。
例如:在向用户显示提示用户保存文档的对话框之前引发该事件。系统会询问用户是否要使用“是”、“否”和“取消”按钮进行保存。如果用户选择取消,即使引发了DocumentBeforeClose 事件,文档仍保持打开状态。
出于这个原因,有任何方法或方法可以在文档关闭后使event 或Method 成为raised 或run。
我试着这样做:
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
Globals.ThisAddIn.Application.DocumentBeforeClose += new Microsoft.Office.Interop.Word.ApplicationEvents4_DocumentBeforeCloseEventHandler(this.Application_DocumentBeforeClose);
// I want some thing like this
Globals.ThisAddIn.Application.DocumentAfterClose += new Microsoft.Office.Interop.Word.ApplicationEvents4_DocumentOpenEventHandler(this.Application_DocumentAfterClose);
}
public void Application_DocumentBeforeClose(Word.Document doc, ref bool Cancel)
{
MessageBox.Show(doc.Path, "Path");
}
// I want some thing like this
public void Application_DocumentAfterClose(string doc_Path)
{
MessageBox.Show(doc_Path, "Path");
}
【问题讨论】:
标签: c# ms-word vsto office-interop word-addins