PDA

View Full Version : Solved: Printout Problems



chungtinhlak
10-15-2009, 06:01 AM
I have over 50 reports that I have to print to 5 different printers every morning. I use if statement to control what printer it goes to.

I record a macro to get the code to print. However, Everyday, it give me an error saying that the activeprinter method fail. So I have to re-record a macro and paste it in again. When I re-record, the only thing i notice changing was "On Ne02:" it got change to a different port maybe "ON Ne10" or Ne08.

Is there a way around this problem?


Application.ActivePrinter = "\\Printerserver\Printername (file://Printerserver/Printername) on Ne02:"
ActiveWindow.SelectedSheets.PrintOut Copies:=2, ActivePrinter:= _
"\\Printerserver\Printername (file://Printerserver/Printername) on Ne02:", Collate:=True

mdmackillop
10-15-2009, 07:03 AM
You can use the code in this KB item (http://vbaexpress.com/kb/getarticle.php?kb_id=528)to get the port each time you print. The Userform is not required.

chungtinhlak
10-15-2009, 08:42 AM
thanks mdmackillop,

Can you help me get this to work, I been messing with it for a couple hours now but it doesn't seem to do anything. There are 3 function but I can't figure with function to call first.

thanks

chungtinhlak
10-15-2009, 09:04 AM
I think i got it :) thanks

mdmackillop
10-15-2009, 09:07 AM
You just need

Application.ActivePrinter = GetPrinterKey(PrinterName)

chungtinhlak
10-15-2009, 10:05 AM
yup, go it, thanks