Programming Questions? Ask a Programmer for Answers ASAP
Here is the code for selecting a printer
Application.ActivePrinter = "XYZ"
Where XYZ is your printers name
Now to find the exact printer that the code should use, record a new macro, then go to the Print command. When the Print dialog box opens, select the printer that you want to use, and click OK. Now stop the macro and go to the recorded code and you will see the full name of the printer. That is the exact name that you should use in your code.
Hope this is helps. Let me know if you have any questions, and thank you for clicking Accept if you are satisfied with the answer
This method works with Office 2007 and earlier versions, in fact I have been using it for years, but I haven't been able to make it work with 2010 version.
hmm.. It should also work in 2010.
Could you record a new macro in Excel 2010 and change the printer when the recording is on, then stop the recording and copy the code and paste it here. I want to see the exact printers name
When you record it in a macro it makes the changes between printers that you select but it doesn't record the printer details in the macro so the next time you run the macro it just prints to the currently elected printer.
I have worked out a solution .... what you have to do is enter the following:
MsgBox "The name of the active printer is " & _ Application.ActivePrinter
This will give you the description of the currently elected printer and then you can enter it into the Application.ActivePrinter =" "
Yes that is the correct way to do it. Good job.
Thanks for sharing