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:
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.