开发者

Excel: How to get a locale-independent printer name?

开发者 https://www.devze.com 2022-12-18 02:12 出处:网络
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

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, th开发者_运维百科is 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.


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/


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!

0

精彩评论

暂无评论...
验证码 换一张
取 消