Set default printer for form

  • Thread starter Thread starter Jarryd
  • Start date Start date
J

Jarryd

Hi,

I want to make use of the MS Document Image Writer in my Access 2003 DB. To
make it simple for people I wanted to put a button on a form that would
print the current record to the Image Writer, and all they have to do is
give it a name and save it. So how do I set the default printer to a specif
form to use the image writer, so that it doesn't affect the rest of the
forms?

TIA,

Jarryd
 
Hi,

Got some code that did if for me. I have copied it below in case someone
finds it useful:

Dim objDefaultPrinter As Printer ' Current printer
Dim objNewPrinter As Printer ' New printer
Dim objThisPrinter As Printer ' Printer for loop
Dim strNewPrinter As String ' Device name of new printer

strNewPrinter = "London Colour 1"

' Store the current printer
Set objDefaultPrinter = Application.Printer
Set objNewPrinter = objDefaultPrinter

' Loop through all the installed printers
For Each objThisPrinter In Application.Printers

' If the device names match, set printer to new one

If Len(objThisPrinter.DeviceName) >= Len(strNewPrinter) Then

If Right(objThisPrinter.DeviceName, Len(strNewPrinter)) =
strNewPrinter Then

Set objNewPrinter = objThisPrinter

End If

End If

Next

If objDefaultPrinter.DeviceName = objNewPrinter.DeviceName Then

MsgBox "Printer " & strNewPrinter & " not found"

End If

Application.Printer = objNewPrinter

' Do stuff

Application.Printer = objDefaultPrinter

Cheers,

Jarryd
 
Back
Top