Home > Software engineering >  VB Settings button for the native printer list
VB Settings button for the native printer list

Time:09-27

need to click the button, get the machine printer list, select one of the printer to print, the novice help ha!

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
  • Related