Setting Printer by Code??

  • Thread starter Thread starter Don V
  • Start date Start date
D

Don V

Here's the code I have.
What am I doing wrong?
I'm attempting to change the printer from a command button
It works but prints out on my default printer and does not change the
printer to Winfax.


Private Sub cmdFax_Click()

On Error GoTo Err_cmdFax_Click

Set Application.Printer = Application.Printers("WinFax")
DoCmd.PrintOut acSelection
Exit_cmdFax_Click:
Exit Sub

Err_cmdFax_Click:
MsgBox Err.Description
Resume Exit_cmdFax_Click
End Sub


Don
 
Are you use you have the right printer name?

Try removing the error code, and see what happens.

You can also try running the following code in a module, and see what the

actual printer names are:

Dim i As Integer

For i = 0 To Application.Printers.Count - 1
Debug.Print Application.Printers(i).DeviceName
Next i

The above results are sent to the debug window.
 
Are you use you have the right printer name?
<Snip>
Thanks for the reply.
I have the right printer name. I'm wondering if the problem lies in the
fact I'm trying to do this from a command button on a form.

Don
 
My guess is that you perhaps has report with the printer set.

I would also consider setting the printer before you open the report.

If you are trying to print a form, then get rid of that idea, and use a
report.
 
Back
Top