Skip to main content

[Migrated content. Thread originally posted on 14 April 2006]

We have been retrieving printer information in a COBOL program using 6.0 runtime so we can pass the printer name along to use in EXCEL. The code looks like this:



CALL "win$printer" using winprint-get-current-info-ex

winprint-selection

GIVING WSS-PRINTER-RESULT.



We then use the winprint-name and winprint-port to pass to excel.

Eventually we set the active printer for excel like this:

modify olexcel @activeprinter = winprint-name1.

Winprint-name1 is the concatenation of the winprint-name and winprint-port values.

This code works fine in 6.0. but now we are trying to upgrade to the 7.0.1 runtime and there seems to be a change in what is returned in the winprint-port value.

The value returned to us in winprint-selection, winprint-port, in 6.0

is: "Ne09", but when we execute this same code in 7.0.1 the value returned in winprint-port is "IP_10.1.2.10_newest".

The printer name we used to be able to pass in 6.0 , that worked, was "\\\\Printserver\\MIS Laser on Ne09 " .

The printer name that gets passed in 7.0.1, and does not work, is "\\\\Printserver\\MIS laser on IP_10.1.2.10_newest " .

Does anyone have any suggestions on how we can get back to getting the port name "Ne09" to pass to Excel?

thanks.
Mark G.

[Migrated content. Thread originally posted on 14 April 2006]

We have been retrieving printer information in a COBOL program using 6.0 runtime so we can pass the printer name along to use in EXCEL. The code looks like this:



CALL "win$printer" using winprint-get-current-info-ex

winprint-selection

GIVING WSS-PRINTER-RESULT.



We then use the winprint-name and winprint-port to pass to excel.

Eventually we set the active printer for excel like this:

modify olexcel @activeprinter = winprint-name1.

Winprint-name1 is the concatenation of the winprint-name and winprint-port values.

This code works fine in 6.0. but now we are trying to upgrade to the 7.0.1 runtime and there seems to be a change in what is returned in the winprint-port value.

The value returned to us in winprint-selection, winprint-port, in 6.0

is: "Ne09", but when we execute this same code in 7.0.1 the value returned in winprint-port is "IP_10.1.2.10_newest".

The printer name we used to be able to pass in 6.0 , that worked, was "\\\\Printserver\\MIS Laser on Ne09 " .

The printer name that gets passed in 7.0.1, and does not work, is "\\\\Printserver\\MIS laser on IP_10.1.2.10_newest " .

Does anyone have any suggestions on how we can get back to getting the port name "Ne09" to pass to Excel?

thanks.
Mark G.
We were able to figure out another way to get the printer port. We are now using REG_OPEN_KEY and REG_QUERY_VALUE_EX to read the windows registry value at HKEY_CURRENT_USER\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Devices
using the value of the printer the user selects and returning the port value.

[Migrated content. Thread originally posted on 14 April 2006]

We have been retrieving printer information in a COBOL program using 6.0 runtime so we can pass the printer name along to use in EXCEL. The code looks like this:



CALL "win$printer" using winprint-get-current-info-ex

winprint-selection

GIVING WSS-PRINTER-RESULT.



We then use the winprint-name and winprint-port to pass to excel.

Eventually we set the active printer for excel like this:

modify olexcel @activeprinter = winprint-name1.

Winprint-name1 is the concatenation of the winprint-name and winprint-port values.

This code works fine in 6.0. but now we are trying to upgrade to the 7.0.1 runtime and there seems to be a change in what is returned in the winprint-port value.

The value returned to us in winprint-selection, winprint-port, in 6.0

is: "Ne09", but when we execute this same code in 7.0.1 the value returned in winprint-port is "IP_10.1.2.10_newest".

The printer name we used to be able to pass in 6.0 , that worked, was "\\\\Printserver\\MIS Laser on Ne09 " .

The printer name that gets passed in 7.0.1, and does not work, is "\\\\Printserver\\MIS laser on IP_10.1.2.10_newest " .

Does anyone have any suggestions on how we can get back to getting the port name "Ne09" to pass to Excel?

thanks.
Mark G.
This is expected behavior.
The Nexx: construction is for Windows to present a port for applications that have no means to handle real portnames, because they were originally designed to handle f.ex. LPTx: and COMx:.

The suggestion about using the registry to find the mapping is a good one.

Alternatively you can use the API function EnumPorts, with PORT_INFO_2, you will get both the real port name, and the NExx: abbreviation.