Excel:如何获取与区域设置无关的打印机名称?

发布于 2024-08-19 12:51:55 字数 513 浏览 4 评论 0原文

Excel 中有一个 PrintOut 方法可以打印内容。 它接受打印机名称作为参数,并且该打印机名称不仅仅是系统打印机名称,而是系统打印机名称和打印机连接的端口的组合。

.PrintOut ActivePrinter:="MyPrinter" & " on " & "Ne00:"

如果您只提供系统名称,Excel 将找不到它并且不会打印。

请注意中间的 " on " 部分。正是英文单词“on”使“excel打印机名称”变得人性化。

问题是,这个小片段在每个本地化版本的 Excel 上都是不同的。因此,想要组成真正的“Excel 打印机名称”的代码需要包含一个巨大的开关,其中将列出所有可能的 Excel 区域设置以及相应的“on”翻译。我连这样的清单都没有。但我想拥有它,或者想听听一种即时解决这个问题的方法。 Application.International 属性似乎不包含答案。

There's a PrintOut method in Excel that prints stuff.
It accepts a printer name as a parameter, and that printer name is not just a system printer name, but a combination of both system printer name and port to which the printer is connected.

.PrintOut ActivePrinter:="MyPrinter" & " on " & "Ne00:"

If you only provide a system name, Excel will not find it and will not print.

Note that " on " piece in the middle. It is actual English word "on" that makes "excel printer name" human-friendly.

The problem is, this little piece is different on each localised version of Excel. Therefore, code that wants to compose true "excel printer name" would need to include a huge switch where all possible Excel locales would be listed with corresponding translation of "on". I haven't even got such list. But I would like to have it, or to hear about a way to figure out this piece on the fly. The Application.International property does not seem to contain an answer.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

单调的奢华 2024-08-26 12:51:55

的注册表项

这个家伙使用\HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Devices\

http://www.dailydoseofexcel.com/archives/2008/04/05/getting-the-printer-port/

This guy uses the registry entries at

\HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Devices\

http://www.dailydoseofexcel.com/archives/2008/04/05/getting-the-printer-port/

心舞飞扬 2024-08-26 12:51:55

您可以首先读取ActivePrinter 属性。它将根据区域设置返回字符串。获得该字符串后,您就可以获得要使用的“on”的确切版本!

You can first read the ActivePrinter property. It will return the string as per the locale. Once you have the string, you can get what exact version of "on" to use!

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