MS Word 中有 DocumentAfterPrint 事件吗?

发布于 2024-07-29 01:51:05 字数 234 浏览 4 评论 0原文

我正在做一个项目,我需要在打印后将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 技术交流群。

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

发布评论

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

评论(3

憧憬巴黎街头的黎明 2024-08-05 01:51:05

这是一种解决方法基于子程序名称。 我不相信存在您想要的特定 DocumentAfterPrint 事件。 这是代码:

Sub FilePrint()
'To intercept File > Print and CTRL-P'

MyPrintSub

End Sub

Sub FilePrintDefault()
'To intercept the Standard toolbar button'

MyPrintSub

End Sub

Sub MyPrintSub()

Dialogs(wdDialogFilePrint).Show
'Your code here, e.g:'
MsgBox "I am done printing."

End Sub

更新:请注意下面 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:

Sub FilePrint()
'To intercept File > Print and CTRL-P'

MyPrintSub

End Sub

Sub FilePrintDefault()
'To intercept the Standard toolbar button'

MyPrintSub

End Sub

Sub MyPrintSub()

Dialogs(wdDialogFilePrint).Show
'Your code here, e.g:'
MsgBox "I am done printing."

End Sub

UPDATE: Please note the gotchas in Will Rickards' answer below.

落在眉间の轻吻 2024-08-05 01:51:05

查看应用程序事件我没有看到它。
我在文档事件中也没有看到它。
请注意上面提供的解决方法,即使用 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.

一场信仰旅途 2024-08-05 01:51:05

我不认为任何建议的解决方法都适用于 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 the documentBeforePrint event to cause another procedure to be executed a few seconds later.

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