views:

161

answers:

2

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.

+1  A: 

this helped me a lot in problem very close to yours.

Sergey Mirvoda
Sounds promising, but because the thread is five years old, links do not work, nor do the suggested search keywords. Can you provide an actual link to the function mentioned?
GSerg
wow ... five years:) I'll try to search in our codebase
Sergey Mirvoda
Any luck with the codebase?..
GSerg
I guess not :-(
GSerg
A: 

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/

Dick Kusleika
I know how to get printer's port.This guy is doing it wrong, btw. Correct way, for compatibility reasons, is to use GetProfileString function. But my question is about different problem.
GSerg
Sorry, I misread the question.
Dick Kusleika