MS Word Interop:取消(不显示)“保存更改”关闭对话框
我使用 MS Interop 为用户打开生成的文件,允许他们编辑它,然后关闭它,然后我为他们保存它(这是一个更大过程的一部分)。由于用户不需要手动保存文件,我想在用户尝试关闭文档时取消保存文件的弹出对话框。在 DocumentBeforeClose 事件的处理程序中,以下内容似乎对我不起作用:
App.ActiveDocument.Saved = true;
这似乎应该将 Word 文档标记为已保存,但事实并非如此。
有人遇到过这个问题吗?
-nomad311
I'm using MS Interop to open a generated file for a user, allow them to edit it and then close it, after which I save it for them (it's part of a larger process). Since the user doesn't need to save the file manually I would like to cancel that pop up dialog to save the file when the user tries to close the document. The following doesn't seem to work for me in a handler for the DocumentBeforeClose event:
App.ActiveDocument.Saved = true;
This seems like it should mark the Word document as saved, but doesn't.
Anyone come across this issue?
-nomad311
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现我正在通过从 DocumentBeforeClose 事件处理程序调用文档的 SaveAs() 方法来创建事件链。但是,我在 DocumentBeforeSave 事件处理程序中取消了保存(旨在仅停止用户保存)。因此,取消链......这会停止关闭操作,但“保存更改”弹出窗口仍然会启动?!
...我想我应该把这个说清楚,以防其他人像我一样切肉:)
-nomad311
I found out I was creating a chain of events by calling the SaveAs() method of the document from the DocumentBeforeClose event handler. But, I was canceling the save (intended to only stop a user save) in the DocumentBeforeSave event handler. Thus, canceling the chain ...which stops the close operation, but the 'save changes' pop-up still gets launched?!
...Thought I would spell this out in case someone else gets as cleaver as I did :)
-nomad311