User selecting printer

Steve2003

Registered User.
Local time
Today, 22:24
Joined
Jun 20, 2003
Messages
16
I have set a form up that reads all of the printers available on my network and puts them into a list box. Then the user selects the printer they want to print to and clicks the print button.

The idea is to allow me to test if someone is printing to a pdf file and if they are, asking them if they want to add the company logos to the form they are trying to print. The reason the logos have to be imported is that if the form is printed normally it will go on headed paper.

The code below will show via a message box a change in printer devicename but when you print it actually does not change to the printer selected.

Any help much appreciated.

Steve

Private Sub btnPrintForm_Click()
On Error GoTo Err_btnPrintForm_Click

Dim stDocName As String
Dim MyForm As Form



'PS= Printer Selected
Dim PS As String
PS = Me.txtSelectedPrinter

'Ask if EFR logos and banner to be inserted as
'printing to pdf
If PS = "Acrobat Distiller" Or _
PS = "FinePrint pdfFactory pro" Then

BandL.B_L_Insert
End If




stDocName = Me.txtFormNameToPrint

Set MyForm = Screen.ActiveForm
DoCmd.SelectObject acForm, stDocName, True

'change printer to selected
Set Application.Printer = Application.Printers(PS)
MsgBox& Application.Printer.DeviceName

'DoCmd.PrintOut acPrintAll, , , , Me.txtNoOfCopies
DoCmd.SelectObject acForm, MyForm.Name, False

BandL.B_L_Remove


Exit_btnPrintForm_Click:
Exit Sub

Err_btnPrintForm_Click:
MsgBox Err.Description
Resume Exit_btnPrintForm_Click

End Sub
 
Steve, see the attachment for another way to allow the user to select the printer, it might be of use to you

A2K, AXP versions
 

Attachments

Meltdown,

Thankyou for your reply.

Unfortunately it does not seem to work. I am using Access 2000 so I selected that option but it is always printing to the default printer. The same problem as I had before. Although putting msgboxes in certain places to find out the string you are trying to put to is the one you have chosen and it showing that it is, the actual printer is not being changed.

Any further help would be much appreciated.

Steve Jukes
 
I think the only way is to use the PrtDevNames and PrtDevMode properties.
 

Users who are viewing this thread

Back
Top Bottom