MS Word Interop:取消(不显示)“保存更改”关闭对话框

发布于 2024-08-07 08:35:27 字数 290 浏览 1 评论 0原文

我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

随心而道 2024-08-14 08:35:27

我发现我正在通过从 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文