Excel VBA print to specific printer tray

六月ゝ 毕业季﹏ 提交于 2020-01-03 03:09:07

问题


In Excel (2007) VBA how do I print the worksheet to a specific printer tray? This will just print to the default tray on the printer:

ws.PrintOut ActivePrinter:="\\print_server\printer_name"

回答1:


Microsoft offers one ugly solution to this problem; using SendKeys to manually choose the correct tray from the print settings dialog box.

Another option may be to set up additional printers in Windows, where each printer is actually linked to a different tray on the same printer. You could then select the appropriate tray in VBA. This article has the details.

Or, if your printer happens to have a different size of paper in the tray you want to print to, you can set (for example):

ws.PageSetup.PaperSize = xlPaperLegal

And the printer will automatically select the correct tray. I just tried this out on my printer here, and it forced the sheet to print on the manual tray, because I don't actually have a legal size paper tray.



来源:https://stackoverflow.com/questions/770230/excel-vba-print-to-specific-printer-tray

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