【发布时间】:2017-01-23 14:13:49
【问题描述】:
我有一些代码列出了所有活动的打印机(但在 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。
我希望这是有道理的。在此先感谢您的帮助。 ——弗拉基米尔
【问题讨论】:
标签: vba ms-access printing device-name