Code: Select all
Sub CARICA_PRINTER()
On Error GoTo Err_SomeName
If Me.COMBO_PRINTER.ListCount = 0 Then
For Each P In Printers
Me.COMBO_PRINTER.AddItem UCase(P.DeviceName)
Next
End If
Exit_SomeName:
Exit Sub
Err_SomeName:
MsgBox Err.Number & Err.Description
Resume Exit_SomeName
End Sub
how to set the printer in selected combobox?
i use this code but not work!
Code: Select all
Sub PrintToPrinter()
On Error GoTo PrintError
Set Printer = Me.COMBO_PRINTER <<<<< error here
Printer.PaperSize = vbPRPSA4
Printer.FontName = "Courier New"
Printer.FontSize = "9"
Printer.Orientation = 2
If InStr(Me.SCROLL_OP.Text, "APERTURA ORDINE NUMERO:") > 0 Then
Printer.Print vbNewLine &[b] "DATA CONTABILE " & Me.DATA_CONT.Caption & Space(5) & "AGENZIA " & Me.AGENZIA.Caption & Space(10) & "MATRICOLA " & Me.Label5.Caption & Space(5) & "STAMPATO IL " & Format(CDate(Now), "DD/MM/YYYY") & Space(5) & "NR. OPERAZ. " & CONTA1 & [/b]Chr(13) & Chr(13) & Me.SCROLL_OP.Text
Else
Printer.Print vbNewLine &[b] "DATA CONTABILE " & Me.DATA_CONT.Caption & Space(5) & "AGENZIA " & Me.AGENZIA.Caption & Space(10) & "MATRICOLA " & Me.Label5.Caption & Space(20) & "STAMPATO IL " & Format(CDate(Now), "DD/MM/YYYY")[/b] & Chr(13) & Chr(13) & Me.SCROLL_OP.Text
End If
Printer.EndDoc
Exit Sub
PrintError:
MsgBox "Error number: " & Err.Number & vbCrLf & "Description: " & Err.Description & "" & Chr(13) & "" & Chr(13) & "May be printer is still off or out of paper." & Chr(13) & "Please turn on your printer now or fill in " & Chr(13) & "the paper to printer. Then, try again.", vbCritical, "Printer Error"
Exit Sub
End Sub
Printer.FontName = "Courier New"
Printer.FontSize = "9"
and bold only the line signed with bold marked code?