CodePudding user response:
Add the function SelectPrinter ()'Form1
'put a ListBox, a CommandButton
Option Explicit
Private Sub Command1_Click ()
SelectPrinter List1. Text
Printer. Print "Hello"
Printer. EndDoc
End Sub
Private Sub Form_Load ()
Dim PRT As Printer
For Each PRT In Printers
List1. AddItem PRT. DeviceName
If PRT, DeviceName=Printer DeviceName Then
List1. ListIndex=List1. NewIndex
End the If
Next
End Sub