VBA in Excel - Change Active Printer

I have an excel sheet that I has a button that when clicked should print the print area as a PDF (or save as instead, but I have the print part working) and then show me a Print Preview of the same page so that I can review and optionally click "print" and send it to a physical printer.  However, the print to PDF is changing the active printer to the PDF now forcing me to change it back manually every time - this is unacceptable.

I would have thought there was a fairly easy way to tell Excel "on the next print attempt (Or more specifically, PRINT PREVIEW), use this printer"

I might be able to debug from other code and figure it out but I'm apparently experiencing logic/google foo problems and cannot come up with a timely answer.

So, without ACTUALLY initiating the printing, how to I set the excel sheet to target a specific printer the next time I print (I keep getting Run-time error '1004': Method 'ActivePrinter' of object '_Global' failed when I attempt to change it with what would seem the obvious answer ActivePrinter = "\\server\PrinterShare"
LVL 97
Lee W, MVPTechnology and Business Process AdvisorAsked:
Who is Participating?
Rory ArchibaldConnect With a Mentor Commented:
If you want to send it to the same printer that was selected before your code printed to PDF, you can store that information prior to printing
Dim sCurrentPrinter as string
sCurrentPrinter = application.activeprinter
' your code to print to pdf goes here

' reset printer
application.activeprinter = sCurrentPrinter

Open in new window

The reason your code above failed is that the printer string needs to have information about the printer port on the end - so it should always end in something like " on NE01"

Could you try
yourPrinter= Application.ActivePrinter

Open in new window

To determine the correct name of the printer you want

Martin LissOlder than dirtCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
All Courses

From novice to tech pro — start learning today.