Printers 集合包含代表當(dāng)前系統(tǒng)中所有可用打印機(jī)的 Printer 對(duì)象。
使用 Application 對(duì)象的 Printers 屬性可以返回 Printers 集合。使用 For Each...Next 語句,可以循環(huán)遍歷 Modules 集合。下面的示例顯示系統(tǒng)所有可用打印機(jī)的有關(guān)信息。
For Each prtLoop In Application.Printers
With prtLoop
MsgBox "Device name: " & .DeviceName & vbCr _
& "Driver name: " & .DriverName & vbCr _
& "Port: " & .Port
End With
Next prtLoop
通過按名稱或按其在集合中的索引引用打印機(jī),可以引用 Printers 集合中的單個(gè) Printer 對(duì)象。
Printers 集合的索引從零開始。如果按其索引來引用打印機(jī),則第一臺(tái)打印機(jī)是 Printers(0),第二臺(tái)打印機(jī)是 Printers(1),以此類推。
不能在 Printers 集合中添加或刪除 Printer 對(duì)象。