MS Word 中有 DocumentAfterPrint 事件吗?
我正在做一个项目,我需要在打印后将word文档返回到特定状态。 我找到了 DocumentBeforePrint 事件,但我找不到找到 DocumentAfterPrint 事件。 它的文档记录不足还是存在其他解决方法?
I am working on a project where I need to return a word document back to a certain state after it is printed. I have found a DocumentBeforePrint event but I cannot find a DocumentAfterPrint event.
Is it poorly documented or is there some other workaround that exists?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是一种解决方法基于子程序名称。 我不相信存在您想要的特定
DocumentAfterPrint
事件。 这是代码:更新:请注意下面 Will Rickards 答案中的问题。
Here is one workaround based on subroutine names. I do not believe there is a specific
DocumentAfterPrint
event like you desire. Here's the code:UPDATE: Please note the gotchas in Will Rickards' answer below.
查看应用程序事件我没有看到它。
我在文档事件中也没有看到它。
请注意上面提供的解决方法,即使用 FilePrint 和 FilePrintDefault 方法,您应该阅读 这个网站。 这些方法取代了内置函数。 因此,您实际上需要在其中添加代码或生成代码才能实际打印单词。
此外,后台打印可能会导致您的代码在完成打印之前执行。 如果您确实必须在打印后运行某些内容,则需要禁用后台打印。
Looking at the application events I don't see it.
I don't see it in the document events either.
Please note on the workaround provided above, that is using the FilePrint and FilePrintDefault methods, you should read this site. These methods replace the built-in function. So you actually need to add code in there or have it generated for you to get word to actually print.
Also background printing can cause your code to execute before it has finished printing. If you really must run something after it has printed you'll need to disable background printing.
我不认为任何建议的解决方法都适用于 Word 2010。但是,我通过在
documentBeforePrint< 末尾使用
application.onTime()
方法取得了成功。 /code> 事件导致几秒钟后执行另一个过程。I don't believe any of the suggested work-arounds will work in Word 2010. However, I have had success by using the
application.onTime()
method at the end of thedocumentBeforePrint
event to cause another procedure to be executed a few seconds later.