I am trying to allow a user to select a printer to print out a crystal designer report without changing the default printer setting. The code below works great for the print job but it changes the default printer to what is selected. I tried various approaches mentioned here at Codeguru but none of them are shifting the printer back to the original default. What’s strange about this is if I put a msgbox in the code to see if the Printer object is back to the default it is but not when you then look in settings or re-open the common dialog box. Also, for some reason the Printer object has a different port designation than that which comes from the Printers collection. Only the latter will work with the SelectPrinter method. Maybe a totally different approach would be better.

Private Sub CRViewer1_PrintButtonClicked(UseDefault As Boolean)

UseDefault = False
On Error GoTo CancelError
CommonDialog1.CancelError = True

'needs to be True to set Printer Object
CommonDialog1.PrinterDefault = True
CommonDialog1.ShowPrinter

'get proper port designation
Dim prt As Printer
For Each prt In Printers
If prt.DeviceName = Printer.DeviceName Then
Dim a As String
Dim B As String
Dim C As String
a = prt.DriverName
B = prt.DeviceName
C = prt.Port
crxReport9.SelectPrinter a, B, C
Exit For
End If
Next

crxReport9.PrintOut False
Printer.EndDoc

'''’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’
‘Restore default printer
'Need Help here.
‘if use Printers collection to get the original default printer and
‘then state Set Printer = originaldefaultprinter the Printer object
‘is set but not the System Printer.
''''''''''''''''''''''''''''’’’’’’’’’’’’’’’’’’’’’

Exit Sub

CancelError:
MsgBox "Printing Canceled"

End Sub