如何确定是否“SaveChanges:=wdDoNotSaveChanges”被传递给 Interop.Word.Document.Close()
我正在处理的 Office 插件存在问题,该插件是针对 Office 2003 和 Office 2003 实现的。 2007 年。该插件是使用 VSTO 在 VB.NET 3.5 中编写的。
问题来自于一些外部代码,这些代码自动执行邮件合并、打开邮件合并模板、合并然后关闭模板文档。关闭是通过以下代码完成的:
objWord.Documents(sDoco).Close SaveChanges:=wdDoNotSaveChanges, OriginalFormat:=wdPromptUser
由于我的插件中的某些逻辑(由 Interop.Word.Application.DocumentBeforeClose 事件引发),会打开一个消息框,阻止 Office 文档关闭,从而中断自动化。
有没有办法让我确定 Office.Interop.Word.Application
事件中关闭时的 SaveChanges
参数(如果有),例如 DocumentBeforeClose< /代码>?我正在尝试捕获此参数并确定它是否设置为 wdDoNotSaveChanges 以便我可以解决此问题。
I have an issue with an Office addin I'm working on, which is implemented for Office 2003 & 2007. The addin is written in VB.NET 3.5 using VSTO.
The problem comes from some external code which automates a mail merge, opening the mail merge template, merging and then closing the template document. The close is done with this code:
objWord.Documents(sDoco).Close SaveChanges:=wdDoNotSaveChanges, OriginalFormat:=wdPromptUser
Because of some logic in my addin, instigated from the Interop.Word.Application.DocumentBeforeClose
event, a message box is opened which prevents the Office document from closing, which breaks the automation.
Is there a way for me to determine the SaveChanges
parameter (if any) on a Close within an Office.Interop.Word.Application
event, such as DocumentBeforeClose
? I'm trying to capture this parameter and determine if it's set to wdDoNotSaveChanges
so that I can work around this problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我很确定您会在 DocumentBeforeClose 之前收到 DocumentSave 事件,因此在其中设置一个标志,如果在关闭时设置该标志,您就知道文档已被保存,但如果没有,则没有。我必须做类似的事情才能知道文档是保存为还是刚刚保存。
我不知道有什么方法可以从 DocumentBeforeClose 询问该参数的状态。
I'm pretty sure you get the DocumentSave event BEFORE the DocumentBeforeClose, so set a flag in it, and if that flag is set at close, you know the doc has been saved, but if not, it was not. I've had to do similar things to know whether a Document was SAVED-AS vs just SAVED.
I'm not aware of any way to interrogate the state of that parameter from DocumentBeforeClose.