表示所有 打印机 对象的集合,每个对象表示计算机上安装的打印机之一。
备注
若要让用户能够选择打印机来打印出版物,可以循环访问 InstalledPrinters 集合以获取计算机上安装的所有打印机的名称列表。
InstalledPrinters 集合的默认属性是 项目 。
示例
以下Microsoft Visual Basic for Applications (VBA) 宏显示了如何使用 Printer 对象的 PrinterName 和 IsActivePrinter 属性来获取计算机上所有已安装打印机的列表,并确定其中哪些打印机当前是活动打印机。
Public Sub InstalledPrinters_Example()
Dim pubInstalledPrinters As Publisher.InstalledPrinters
Dim pubApplication As Publisher.Application
Dim pubPrinter As Publisher.Printer
Set pubApplication = ThisDocument.Application
Set pubInstalledPrinters = pubApplication.InstalledPrinters
For Each pubPrinter In pubInstalledPrinters
Debug.Print pubPrinter.PrinterName
If pubPrinter.IsActivePrinter Then
Debug.Print "This is the active printer."
End If
Next
End Sub
属性
另请参阅
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。