【发布时间】:2018-11-30 20:10:37
【问题描述】:
我的客户希望我遍历他的标签打印打印机并找到可用的。
我不在他的办公室,所以只能在没有找到他的情况下将其默认为我的本地打印机。除了,它只在我端打印为 PDF。我什至取消选中“让 Windows 管理您的打印机选择”框。它不断出现pdf。
这是我机器上的打印机列表
0 Send To OneNote 2016
1 PDFill PDF&Image Writer
2 Microsoft XPS Document Writer
3 Microsoft Print to PDF
4 Fax
5 Brother HL-2280DW
我做错了什么?
这是我的代码:
Private Sub cmdPrintWTOutgoingLabels_Click()
Dim LABELprinter As Integer
'check that fields are filled in
If Not IsNumeric(Me.cboOutgoingWT) Then
MsgBox "Please select a work ticket number first"
Exit Sub
Else
Dim printerFound As Boolean
Dim numprinters As Integer
printerFound = False
numprinters = Application.Printers.Count - 1
For h = 0 To numprinters
LABELprinter = Hex(h)
'if it errors, don't run the code that exits the loop
On Error GoTo stay_in_loop
Debug.Print LABELprinter & " " & Application.Printers(h).DeviceName
If Application.Printer.DeviceName = "ZDesigner GK420d on Ne" & CStr(LABELprinter) & ":" Then
Set Application.Printer = Application.Printer(h) '"ZDesigner GK420d on Ne" & CStr(LABELprinter) & ":"
printerFound = True
Exit For
End If
stay_in_loop:
Next h
'start error trapping again
On Error GoTo 0
If printerFound = False Then
Set Application.Printer = Application.Printers(5) 'hard coded to my local printer
'Sheet5.PrintOut
End If
DoCmd.OpenReport "WT Outgoing Report", acViewNormal
End If
End Sub
【问题讨论】: