VBA:临时更改 Windows 7 默认打印机
是否有可能仅更改一项“作业”的 Windows 默认打印机?在 Windows XP / Vista / 7 下无需管理员权限是否可以使用?
我想要做什么:
- 默认打印机是 Canon ABC
- 想要
- 在打印后通过 Epson XYZ 打印想要再次恢复我的默认打印机 Canon ABC。
最好的情况是它无需管理权限且无需“消息框”或 UI 对话框即可工作。
应该在 VBA 下使用或(勉强)在 C# / .NET 下使用
is there any possibility to change the windows default printer for one "job" only? Does it work without having adminstrative permissions under Windows XP / Vista / 7?
what i want to do:
- Default printer is Canon ABC
- want to print via Epson XYZ
- after printing want to having back my default printer Canon ABC again.
Best would be if it will work without administrative permissions and without "messageboxes" or UI Dialogs.
Should be used under VBA or (grudgingly) under C# / .NET
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 C# 中,您可以打印到计算机上安装的任何打印机。您无需更改默认打印机。我不知道它在 VBA 中是否相同,但它在 C# 中有效。
编辑:
由于您的评论,我添加了一个小示例,希望能够引导您:
这将在您在对话框中选择的打印机上打印“Hello”。
In C# you can print to any printer installed on the computer. You don't need to change the default printer. I don't know exactly if it's the same in VBA, but it works in C#.
Edit:
Due to your comment I added a little sample, hoping to lead you on the way:
This will print "Hello" to the printer you've selected in the dialog.
来自 Access 帮助:
以下示例将 Printers 集合中的第一台打印机设置为系统的默认打印机,然后报告其名称、驱动程序信息和端口信息。
编辑:您可以在更改默认打印机之前轻松保存默认打印机,并在打印后重新设置。另外,由于更改默认打印机是一个缓慢的过程,我建议您在更改之前检查默认打印机是什么,以避免不必要的更改。
保存/恢复:
From Access help:
The following example makes the first printer in the Printers collection the default printer for the system, and then reports its name, driver information, and port information.
Edit: You can easily save the default printer before changing it, and set it back again after printing. Also, since changing the default printer is a slow process, I would recommend that you check what is the default printer before changing it, in order to avoid un-necessary changes.
To save/restore:
由于您没有具体说明您的“工作”实际上是什么,我将在这里提供一个更简单的答案。
作为编程方法的替代方法,如果您专门尝试通过特定打印机打印特定的报告,MS Access 中的内置功能可以实现此目的。
只需选择报告的“打印预览”视图,然后选择:“
页面设置”->“页面设置”->“打印预览”。页面选项卡->使用特定打印机 ->然后浏览并选择!
这最终满足了我的需求,所以希望它也能帮助你。
Being that you did not specify what your "job" actually is, I will supply a simpler answer here.
As an alternative to the programmatic methods, if you are specifically trying to print a particular report via a certain printer, there is built-in functionality in MS Access to accomplish this.
Simply select the Print Preview view of your report, and then select:
Page Setup -> Page tab -> Use Specific Printer -> Then browse and choose!
This wound up working for my needs, so hopefully it will help you as well.