![]() |
Setting the active printer
In my office system, I am running XPPro SP2. I have one printer attached
locally to the computer but I have set it up as two printers, each with a different "profile". One "profile" prints on a single side and the other prints double sided. I'm having a problem printing to a selected printer. If I manually set one of the printers as the default in "Printers and Faxes" and set the ActivePrinter to the other printer in VBA, Excel prints to the one I initially specified as default. The ActivePrinter variable is set without any errors so the printer name must be correct. I obtained the printer names by setting the default printer manually and typing ?ActivePrinter in the immediate window. It just doesn't printer to the ActivePrinter. What I would like to do is have the user click a command button which sets the ActivePrinter to a specific printer. Then, all subsequent print jobs print to that printer until a different command button is clicked setting the ActivePrinter to a different printer. In other words, Excel prints to whichever printer is specified as the default regardless if I set the ActivePrinter in VBA. I would like to avoid using Application.Dialogs(xlDialogPrint).Show. Any suggestions would be greatly appreciated. Thank you for your time and expertise. |
Setting the active printer
Try this, you can enter the printer name where you see Microsoft fax on fax, you could use an input box to enter the printer name or something like that! Regards, Simon Sub PrintToAnotherPrinter() Dim STDprinter As String STDprinter = Application.ActivePrinter Application.ActivePrinter = "microsoft fax on fax:" ' change printer ActiveSheet.PrintOut ' prints the active sheet Application.ActivePrinter = STDprinter ' change back to standard printer End Sub -- Simon Lloyd ------------------------------------------------------------------------ Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708 View this thread: http://www.excelforum.com/showthread...hreadid=544525 |
Setting the active printer
With Input Box! Sub PrintToAnotherPrinter() Dim STDprinter As String Dim I2 As Integer For I2 = 1 To 1 t1 = InputBox("Enter Printer Address", "Where to Print?", "") STDprinter = Application.ActivePrinter Application.ActivePrinter = t1.Value ActiveSheet.PrintOut Application.ActivePrinter = STDprinter Next End Su -- Simon Lloy ----------------------------------------------------------------------- Simon Lloyd's Profile: http://www.excelforum.com/member.php...nfo&userid=670 View this thread: http://www.excelforum.com/showthread.php?threadid=54452 |
Setting the active printer
Simon,
Thanks for the response. The problem is not how ActivePrinter is set. Here is the problem in simplified form. If I manually go to "Printers and Faxes" and set 'Printer A' as the default printer and then click a command button with the code: Private Sub CommandButton1_Click() Application.ActivePrinter = "Printer B" ActiveSheet.Printout End Sub The computer will print to Printer A, not B. For me to print to Printer B, I must go back to "Printers and Faxes" and set 'Printer B' as the default. In other words, setting ActivePrinter doesn't seem to do anything. Howard "Simon Lloyd" wrote: Try this, you can enter the printer name where you see Microsoft fax on fax, you could use an input box to enter the printer name or something like that! Regards, Simon Sub PrintToAnotherPrinter() Dim STDprinter As String STDprinter = Application.ActivePrinter Application.ActivePrinter = "microsoft fax on fax:" ' change printer ActiveSheet.PrintOut ' prints the active sheet Application.ActivePrinter = STDprinter ' change back to standard printer End Sub -- Simon Lloyd ------------------------------------------------------------------------ Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708 View this thread: http://www.excelforum.com/showthread...hreadid=544525 |
All times are GMT +1. The time now is 10:04 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com