Port Property Example

This example examines each Printer object in the Printers collection to find one connected to a specific port and makes it the default printer.

Dim P As Object
For Each P In Printers
   If P.Port = "LPT2:" Or P.DeviceName Like "*LaserJet*" Then
      Set Printer = P
      Exit For
   End If
Next P