Highlighted
Absent Member.
Absent Member.
205 views

[archive] Passing printer info to Excel

[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.
0 Likes
2 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] Passing printer info to Excel

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.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Passing printer info to Excel

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.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.