如何检查用户是否正在尝试关闭已打开的Word文档 [英] How to check if user is attempting to close an opened word document

查看:88
本文介绍了如何检查用户是否正在尝试关闭已打开的Word文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过打开word文档为报告生成信息。现在打开单词后,信息仍在运行并替换搜索到的文本框名称。如果用户点击该单词的关闭按钮,它将显示被叫被拒绝的呼叫。(来自HRESUlt的例外)。我应该怎么做才能正确地停止正在运行的word文档并关闭它而不显示错误?



我尝试过:



因此,对于该错误,我使用后台工作程序,因为它能够单独处理。现在我有点解决了这个错误,但是一旦查看单词文档并尝试关闭它甚至仍然处理,我现在得到一个新的错误'消息过滤器指示应用程序正忙。(HRESULT异常:0x8001010A(RPC_E_SERVERCALL_RETRYLATER)) 。我该怎么办?

解决方案

我没有用MS Word做过这个,但我用MS Excel做了很多,这是相同的原则。

我的第一次尝试是使用VBA创建一个Addin for Word,并挂钩MS Word事件。

引用:

我正在尝试使用后台工作者,但我仍然想弄清楚如何。



VBA Addin是一个后台工作者,只是坐在那里,等待一个事件。 / BLOCKQUOTE>

I would like to generate information to a report through opening a word document. Once the word is now opened, the information are still running and replacing the searched textbox names. if ever the user clicked on the close button of the word it will display "Call was rejected by callee.(Exception from HRESUlt)". what should i do to properly just stop the running word document and close it without displaying error?

What I have tried:

so for that error i used background worker for it to be able to process like separately. Now i kinda resolve that error but once look at the word document and try to close it even still processing, i got now a new error for 'the message filter indicated that the application is busy.(Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER)). what should i do?

解决方案

I didn't done this with MS Word, but I did a lot with MS Excel, it is the same principle.
My first try would be to create an Addin for Word using VBA, and hook MS Word events.

Quote:

i am trying to use background worker but i still figuring out how to.


A VBA Addin is a background worker, just sitting there, waiting for an event.


这篇关于如何检查用户是否正在尝试关闭已打开的Word文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆