Printers 集合

         
Application
Printers
Printer

Printers 集合包含代表当前系统中所有可用打印机的 Printer 对象。

使用 Printers 集合

使用 Application 对象的 Printers 属性可以返回 Printers 集合。使用 For Each...Next 语句,可以循环遍历 Modules 集合。下面的示例显示系统所有可用打印机的有关信息。

Dim prtLoop As Printer

For Each prtLoop In Application.Printers
    With prtLoop
        MsgBox "Device name: " & .DeviceName & vbCr _
            & "Driver name: " & .DriverName & vbCr _
            & "Port: " & .Port
    End With
Next prtLoop

通过按名称或按其在集合中的索引引用打印机,可以引用 Printers 集合中的单个 Printer 对象。

Printers 集合的索引从零开始。如果按其索引来引用打印机,则第一台打印机是 Printers(0),第二台打印机是 Printers(1),以此类推。

不能在 Printers 集合中添加或删除 Printer 对象。