我有一些代码列出了所有活动的打印机(但在 msgboxes 而不是列表中这样做)。我对该功能没有任何问题。下面是代码:
If Printers.Count > 0 Then
strMsg = "Printers installed: " & Printers.Count & vbCrLf & vbCrLf
For Each prtLoop In Application.Printers
With prtLoop
MsgBox .DeviceName
End With
Next prtLoop
Else
MsgBox "No printers are installed."
End If
虽然它完成了我本质上需要它做的事情,但我希望它仅在与代码中设置的打印机名称的一部分匹配的打印机时才弹出。例如,如果我有 3 台打印机:
Printer ABC 1
Printer ZZ5 2 (copy)
Printer 123
我希望有一个 If Then 语句可能在
For Each prtLoop In Application.Printers
上面代码的一部分表示如果设备名称是 *ABC 那么它只会弹出“Printer ABC 1”而不是全部 3。
我希望这是有道理的。在此先感谢您的帮助。-弗拉基米尔