PDA

Click to See Complete Forum and Search --> : Print to specific printer?


lilmark
Jul 3rd, 2006, 10:07 AM
I am using Access 2000 and need a little help printing a report to a specific printer. I already have the code to open the report using a macro. But, I am having trouble coming up with code that will print this report to a specific printer on a server.

westconn1
Jul 5th, 2006, 06:18 AM
Application.ActivePrinter = "Black S400 on Ne02:"


this is code for excel, guess it should work in access too

pete

lilmark
Jul 5th, 2006, 03:32 PM
That doesn't work for me.

I don't have the method ActivePrinter as one of my options.

westconn1
Jul 6th, 2006, 02:55 AM
sorry i don't use access so i can't help you

pete

Dnereb
Jul 6th, 2006, 04:17 AM
I've ripped this from som of my code, and think it will help you on your way
in the initial code i select a printer in a listbox to make it active
It might be usefull to you to see how to read out the names of the availeble printers as well (to check if the printer is installed).

Sub SelectPrinter()

Dim Prn As Printer
Dim Names() As String
Dim I As Integer

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

'code to select the printer in a form
'...
'...
'...

'me lstSelectPrinter is a listbox with 2 columns (first is an index )
'Set Application.Printer = Application.Printers(Me.LstSelectPrinter - 1)

Set Application.Printer = Application.Printers(2)


End Sub

lilmark
Jul 6th, 2006, 01:36 PM
I have no clue on what this coding is supposed to be doing. It looks like it runs through all the printers, but I don't see how I have it print to a specific printer.

Dnereb
Jul 6th, 2006, 02:48 PM
I do cycle through the printers in the original code to populate a list box
the printer is set based on the index in the of the listbox if the print button is hit to provide you with code that works without the form i simplified it tot this statment at the end:
Set Application.Printer = Application.Printers(2)

it selects the third printer
I couldn't use specific names in the example because my printers and plotters aren't yours of course

To print to a specific printer you need to cycle through all available printers until you find the one you desire And set the application printer to the index of the printer you wanted. (it's ofcourse wise to store the original printer name to reset the Application.printer to it's original setting on ending your code.