Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Find the Ne Printer Number in Excel VBA

Excel How To

How to Find the Ne Printer Number in Excel VBA

by  sxschech  Posted    (Edited  )
If you print to a specific printer through vba and refer to the printer via its Ne0 number, this will help allow the printer code to work without hard coding the number.

For example: If "Adobe PDF on Ne04:" becomes "Adobe PDF on Ne05:", the code will produce an error. This can happen if new printers are added or if the code is run on multiple computers.

The following link contains a function that will identify the Ne0 number of a given printer:

http://www.excelforum.com/excel-programming/708921-printer-selection-problem-due-to-ne-port-numbering.html

Copy and paste the code into an excel visual basic module.



In the actual macro/code for doing the printing, make the following change:

Code:
Application.ActivePrinter = [red]"Adobe PDF on Ne04:"[/red] 'or whatever Ne0 number it is

to

Code:
Application.ActivePrinter = [red]FindPrinter("Adobe PDF")[/red] 'or whatever the name of the printer to use as the active printer

You can also use the FindPrinter function from the immediate window as well in order to find out the printer number by providing the name of the printer which can be found in the Devices and Printers section of Control Panel.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top