Use VBA to tell Outlook to print to a specific printer

≡放荡痞女 提交于 2021-01-29 18:06:31

问题


Is there any way to write a VBA macro in Outlook that forces a printout to a specific printer (even if it's not necessarily the default printer), similar to the Word

Application.ActivePrinter = "Printer Name"

option? I'd like to create a button that prints the current email and attachments to a specific printer (in this case a PDF printer, but I'm guessing it should be the same principle regardless), but can't seem to find a way to force which printer is used in the code.

Thanks.


回答1:


No, Outlook only exposes MailItem.PrintOut method.

You can save the message in the DOC or RTF format using MailItem.SaveAs, open it in Word, and use the Word Object Model to print it.




回答2:


You can use this:

    Dim WshNetwork As Object
    Set WshNetwork = CreateObject("WScript.Network")
    WshNetwork.setDefaultPrinter "Microsoft Print to PDF"

Fill the string with your printer name.



来源:https://stackoverflow.com/questions/26474072/use-vba-to-tell-outlook-to-print-to-a-specific-printer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!