Here's a Function I wrote which will search the Printers for the specified Devicename of the Printer you want to use.
If it's found the Function will return the Current Printer Devicename and Change to the Specified Printer.
To Restore the Original/Default Printer, just call the Function again with the Initially returned Devicename, eg.
Code:Private Sub Command1_Click() Dim sDefault As String 'Select New Printer sDefault = SelectPrinter("Generic / Text Only") If Len(sDefault) Then 'Do Print Here 'Select Original Printer Call SelectPrinter(sDefault) Else 'Printer Not Found MsgBox "Printer not Found" End If End Sub Private Function SelectPrinter(ByVal sDeviceName As String) As String 'Enumerates the Printers looking for the specified 'Devicename, if found, returns the Current Printer Devicename 'Prior to changing Printers. Dim oPRN As Printer For Each oPRN In Printers If oPRN.DeviceName = sDeviceName Then SelectPrinter = Printer.DeviceName Set Printer = oPRN Exit For End If Next End Function
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]




Reply With Quote