Larry Dunn
03-29-2013, 08:12 PM
In our office, we use several reusable print forms. They may be printed at any station, to a number of different printers. Since the default printer is not visible, selecting a printer can be a pain. The failure to select a printer can result in inadvertent results, like sending a color printout to a non-color printer.
I have worked out a truly simple way to let the user know what printer is currently set to be used for the print job. The only thing I don't do here is remember the current default printer, so it could be reset at the end. In fact, I just now thought of it. Not too hard to add.
At any rate, here's the method I used:
I always use a header sheet to gather any information the user might want to have on the form. On that sheet, I place a command button labeled 'Select Printer,' with the following code:
Private Sub CommandButton1_Click()
MsgBox ("I will now bring up the Printer Dialog." & Chr(10) & "Select a printer, then press the Escape key.")
Application.Dialogs(xlDialogPrint).Show
ActiveSheet.Range("C1").Value = ActivePrinter
End Sub[/Coce]
As you can see, all this does is set the active printer, and put its name in the cell C1, which happens to be convenient in the sheet I was working in. Naturally, there's a second command button that performs the print job. It starts like this:
[Code]Private Sub CommandButton2_Click()
On Error GoTo AnError
ActivePrinter = ActiveSheet.Range("C1").Value
GoTo ProceedWithPrintJob
AnError:
On Error GoTo 0
MsgBox ("Printer selection failed. Select another and try again!")
Exit Sub
ProceedWithPrintJob:
End Sub
So you see, the printer name is placed at C1, and the print job uses the printer name it reads from C1. It's simple, visible to the user, and almost fun!
I have worked out a truly simple way to let the user know what printer is currently set to be used for the print job. The only thing I don't do here is remember the current default printer, so it could be reset at the end. In fact, I just now thought of it. Not too hard to add.
At any rate, here's the method I used:
I always use a header sheet to gather any information the user might want to have on the form. On that sheet, I place a command button labeled 'Select Printer,' with the following code:
Private Sub CommandButton1_Click()
MsgBox ("I will now bring up the Printer Dialog." & Chr(10) & "Select a printer, then press the Escape key.")
Application.Dialogs(xlDialogPrint).Show
ActiveSheet.Range("C1").Value = ActivePrinter
End Sub[/Coce]
As you can see, all this does is set the active printer, and put its name in the cell C1, which happens to be convenient in the sheet I was working in. Naturally, there's a second command button that performs the print job. It starts like this:
[Code]Private Sub CommandButton2_Click()
On Error GoTo AnError
ActivePrinter = ActiveSheet.Range("C1").Value
GoTo ProceedWithPrintJob
AnError:
On Error GoTo 0
MsgBox ("Printer selection failed. Select another and try again!")
Exit Sub
ProceedWithPrintJob:
End Sub
So you see, the printer name is placed at C1, and the print job uses the printer name it reads from C1. It's simple, visible to the user, and almost fun!