ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Printing To A Specified Printer (https://www.excelbanter.com/excel-programming/286975-printing-specified-printer.html)

Steven Pearl

Printing To A Specified Printer
 
What would be the syntax to print 5 copies of the current
worksheet to a designated printer (and where do we get the
printer name from)

Thanks,

Steve

Ron de Bruin

Printing To A Specified Printer
 
Try this

Sub Printtest()
Dim DPrinter As String
DPrinter = Application.ActivePrinter
Application.ActivePrinter = "hp officejet k series on Ne00:"
ActiveSheet.PrintOut Copies:=5
Application.ActivePrinter = DPrinter
End Sub

This macro you can assign to a button

To know the names of your printers
Change to it in the ctrl P dialog (Cancel after choose the printer ) and run
this so you know the name that you must use in the macros

Sub nameprinter()
MsgBox Application.ActivePrinter
End Sub

The PrintOut also have a ActivePrinter argument
I don't know if this will set it back to the old printer when it is done??




--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Steven Pearl" wrote in message ...
What would be the syntax to print 5 copies of the current
worksheet to a designated printer (and where do we get the
printer name from)

Thanks,

Steve




DennisE

Printing To A Specified Printer
 
There is an unforseen consequence of using the suggestion proposed by Ron de
Bruin that you should be aware of: Suppose you specify a specific printer as an
ActivePrinter object, for example,

Application.ActivePrinter="HP LaserJet 4SI on LPT1:"

Then what happens is that the system default printer across the entire Windows
environment is changed to that printer, just as though you went to the Control
Panel and made that change. Not only that, but it will make this change on an
instantaneous basis, so other users in the middle of printing on the system
will have their output messed up accordingly. This not-so-well-known bug in
Excel is documented in MS Knowledge Base Article 209722.

-- Dennis Eisen

Steven Pearl

Printing To A Specified Printer
 

Thanks for the reply. That was exactly what I needed!!


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Steven Pearl

Printing To A Specified Printer
 
That was perfect. One other question. If I want to specify
a specific tray to print to on that printer, can that be
handled by the VB code as well? If so, how?

Thanks a ton.

-----Original Message-----
Try this

Sub Printtest()
Dim DPrinter As String
DPrinter = Application.ActivePrinter
Application.ActivePrinter = "hp officejet k series on

Ne00:"
ActiveSheet.PrintOut Copies:=5
Application.ActivePrinter = DPrinter
End Sub

This macro you can assign to a button

To know the names of your printers
Change to it in the ctrl P dialog (Cancel after choose

the printer ) and run
this so you know the name that you must use in the macros

Sub nameprinter()
MsgBox Application.ActivePrinter
End Sub

The PrintOut also have a ActivePrinter argument
I don't know if this will set it back to the old printer

when it is done??




--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Steven Pearl" wrote in

message ...
What would be the syntax to print 5 copies of the

current
worksheet to a designated printer (and where do we get

the
printer name from)

Thanks,

Steve



.


Ron de Bruin

Printing To A Specified Printer
 
Thanks Dennis

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"DennisE" wrote in message ...
There is an unforseen consequence of using the suggestion proposed by Ron de
Bruin that you should be aware of: Suppose you specify a specific printer as an
ActivePrinter object, for example,

Application.ActivePrinter="HP LaserJet 4SI on LPT1:"

Then what happens is that the system default printer across the entire Windows
environment is changed to that printer, just as though you went to the Control
Panel and made that change. Not only that, but it will make this change on an
instantaneous basis, so other users in the middle of printing on the system
will have their output messed up accordingly. This not-so-well-known bug in
Excel is documented in MS Knowledge Base Article 209722.

-- Dennis Eisen




Ron de Bruin

Printing To A Specified Printer
 
Hi Steven

a specific tray to print to on that printer

Sorry I don't have any experience with this

I hope someone else can help you



--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Steven Pearl" wrote in message ...
That was perfect. One other question. If I want to specify
a specific tray to print to on that printer, can that be
handled by the VB code as well? If so, how?

Thanks a ton.

-----Original Message-----
Try this

Sub Printtest()
Dim DPrinter As String
DPrinter = Application.ActivePrinter
Application.ActivePrinter = "hp officejet k series on

Ne00:"
ActiveSheet.PrintOut Copies:=5
Application.ActivePrinter = DPrinter
End Sub

This macro you can assign to a button

To know the names of your printers
Change to it in the ctrl P dialog (Cancel after choose

the printer ) and run
this so you know the name that you must use in the macros

Sub nameprinter()
MsgBox Application.ActivePrinter
End Sub

The PrintOut also have a ActivePrinter argument
I don't know if this will set it back to the old printer

when it is done??




--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Steven Pearl" wrote in

message ...
What would be the syntax to print 5 copies of the

current
worksheet to a designated printer (and where do we get

the
printer name from)

Thanks,

Steve



.





All times are GMT +1. The time now is 11:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com