i want to use code that looks for the default printer then saves the index then looks for a printer by printer name and defaults that printer and after printing is complete the original printer is put back to been the default printer.
Printable View
i want to use code that looks for the default printer then saves the index then looks for a printer by printer name and defaults that printer and after printing is complete the original printer is put back to been the default printer.
Try something like this:
------------------Code:Private Sub Command1_Click()
Dim sLastPrinter As String
sLastPrinter = SetPrinter("Generic / Text-Only")
If Len(sLastPrinter) Then
'Printer Switched Successfully, do the Printing..
Printer.Print "Printing with a Different Printer.."
Printer.EndDoc
'Switch Back to the Original Printer
Call SetPrinter(sLastPrinter)
End If
End Sub
Function SetPrinter(ByVal PrinterName As String) As String
Dim oPRINTER As Printer
For Each oPRINTER In Printers
If LCase(oPRINTER.DeviceName) = LCase(PrinterName) Then
'Found Specified Printer, Switch to it..
SetPrinter = Printer.DeviceName
Set Printer = oPRINTER
Exit For
End If
Next
End Function
Aaron Young
Analyst Programmer
[email protected]
[email protected]
Certified AllExperts Expert
Thanks Aaron that worked great!!!
:eek:
:)