'--------------------------------------------- 'How To: Choosing a Printer Device at Run time 'Posted: 07-June-00 'Author: Robert L Cannon ' 'Description: Sample program written in response 'to forum question. This shows a very basic 'example of how to allow the user to select the 'printer for the current program at run time. Some 'solutions end up changing the default printer for 'all apps which may not be what you want. '--------------------------------------------- 'Option Explicit Private Sub Form_Load() Dim P As Printer ' Display the current default printer name and port. cboPrinters.Text = Printer.DeviceName lblPort.Caption = Printer.Port ' Loop through the printers collection and check each printer name. For Each P In Printers ' Skip any printers you don't want to appear in the combo box. If P.DeviceName = "Rendering Subsystem" Then 'Don't add it to the combo box. Else ' Add any printers you do want to appear in the combo box. cboPrinters.AddItem P.DeviceName End If Next End Sub Private Sub cboPrinters_Click() Dim P As Printer ' Loop through the printers collection and check each printer name. For Each P In Printers ' If the printers collection name matches the printer selected in the ' combo box, display it's port. If P.DeviceName = cboPrinters.List(cboPrinters.ListIndex) Then lblPort.Caption = P.Port Exit For End If Next End Sub Private Sub cmdOK_Click() Dim P As Printer ' Loop through the printers collection and check each printer name. For Each P In Printers ' If the printers collection name is the same as the printer selected ' in the combo box, set that printer as the applications default printer. If P.DeviceName = cboPrinters.List(cboPrinters.ListIndex) Then Set Printer = P Exit For End If Next ' Optional message box. MsgBox "All printing for this application will be sent to the " & _ Printer.DeviceName & " printer on " & Printer.Port, _ vbOKOnly, "Print" Unload Me End Sub Private Sub cmdCancel_Click() Unload Me End Sub '---------------------------- 'Burt Abreu 'Visual Basic Explorer 'http://www.VBExplorer.com 'June 07, 2000 '----------------------------