Printing a Form to a specific Printer

F

Fester

Is there a way to print a form to a specific printer instead of the
Windows default? I tried to set the printer name but it errors out.

Fester
 
B

Bob Phillips

You could add a Print button, and add this code


Private Sub cmdPrint_Click()
Dim fOK As Boolean
Dim sPrinter As String


With Application
sPrinter = .ActivePrinter
fOK = .Dialogs(xlDialogPrint).Show
End With


If fOK Then
Me.PrintForm
Application.ActivePrinter = sPrinter
End If
End Sub



--

HTH

RP
(remove nothere from the email address if mailing direct)
 
F

Fester

It allows me to select the printer, but it only prints the worksheet
and then prints the form to the Windows default again. Am I stating
this correctly?
 
B

Bob Phillips

Sorry, I gave you the wrong dialog, should be

Private Sub cmdPrint_Click()
Dim fOK As Boolean
Dim sPrinter As String

With Application
sPrinter = .ActivePrinter
fOK = .Dialogs(xlDialogPrinterSetup).Show
End With

If fOK Then
Me.PrintForm
Application.ActivePrinter = sPrinter
End If
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Top