PDA

View Full Version : Solved: Print to non-default printer



BrianLong
10-26-2007, 11:48 AM
I am looking to add some automatic printing at the end of an inport macro that I wrote. Using the search function of these forums I found what I thought was the exact answer to my problem, but I cannot figure out what I am doing wrong. I am trying to adapt the tips found in
vbaexpress.com/kb/getarticle.php?kb_id=528

The code that I have written (stripped down to the print portions) is as follows.

Dim PrintUp as String 'Holds location of network printer upstairs
Dim PrintPDF as String 'Name of PDF printer

PrintUp = "\\ fpserver-dc\ome-cm4520" '(a space added after "\\" to avoid auto linking that is keeping me from making post)
PrintPDF = "Adobe PDF"

Application.ActivePrinter = PrintUp
sheets(2).printout


I will eventually add in code that will print to the correct place depending on what conditions are met... but as it stands it always prints to my default printer... i am starting to waste more paper that I'd like.

Secondly I am not exactly sure what to put down for my PDF printer, that is the title of it in my printers window.

If it makes a difference I am using Vista and the display name of my upstairs printer is "OME-CM4520 on FPSERVER-DC"

Brandtrock
10-26-2007, 04:53 PM
Your code as posted is telling it to print to the printer upstairs. Is that the default printer you are talking about?

Does it still print to the same place if you change the Application.ActivePrinter line to:

Application.ActivePrinter = PrintPDF or not?

You can change your printer settings in Windows Control Panel to Pause Printing for the upstairs printer to save on paper. It will show the print jobs sent to the printer and you can cancel them without printing, if that helps.

Regards,

mdmackillop
10-27-2007, 02:48 AM
Hi Brian,
Welcome to VBAX
I've modified the code in this file
Regards
MD

BrianLong
10-29-2007, 06:25 AM
I am sorry that I haven't been as clear as I needed to be. The upstairs printer is not my default printer. My default printer is in my office with me downstairs.

Also, I used the kb I mentioned as a guide to change active printers, but I did not intend to make a button with my code.

I tried downloading and running the code in your file mdmac, but I got an error "Method 'ActivePrinter' of object '_Application' failed" This is on the line of code
Application.ActivePrinter = GetPrinterKey("PDFCreator")

Thank you ffor the tip about pausing the printer. it will make things much easier on me as I try to figure this out.

Brian

mdmackillop
10-29-2007, 06:31 AM
Hi Brian
Record a macro changing to your upstairs printer. You should get something like
ActivePrinter = UpstairsPrinter on Ne04:
Use the first part instead of PDFCreator in my code. The "on Ne04:" is returned by the complicated stuff. Basically, printers are assigned to Ne00:, Ne01: etc. in alphabetical order.

BrianLong
10-29-2007, 06:41 AM
Using record macro to find the NE## info worked great! Don't know why I hadn't tried that earlier. thank you!