我有一个使用 Visual Studio 2010 创建的 Office 2007 Word 插件,代码如下所示:
Public Class ThisAddIn
Private Sub Application_DocumentChange() Handles Application.DocumentChange
If Application.Documents.Count > 0 Then
MsgBox("document change event.")
End If
End Sub
Private Sub Application_DocumentOpen(Doc As Microsoft.Office.Interop.Word.Document) Handles Application.DocumentOpen
MsgBox("document open event.")
End Sub
End Class
我们的 Word VBA 模板 (.dotm) 很少,其中的宏可以以编程方式打开或关闭文档。
如果 VBA 模板中的宏正在运行,我正在寻找一种不执行这些事件的方法。
如果我们在 VBA 中创建这个插件,我们将创建一个全局布尔变量,并在宏运行时切换它。根据全局布尔变量值,我们将跳过这些文档事件。如何在 Word 插件中实现相同的功能。
我们正在寻找 .net 支持,因此我们正在转向 .net。