InstalledPrinters 对象 (Publisher)

表示所有 Printer 对象的集合,其中每个对象都表示计算机上安装的打印机之一。

备注

若要为用户提供打印出版物的打印机选项,可以循环访问 InstalledPrinters 集合以获取计算机上安装的所有打印机的名称列表。

InstalledPrinters 集合的默认属性是 项目

示例

以下 Microsoft Visual Basic for Applications (VBA) 宏显示如何使用 Printer 对象的 PrinterNameIsActivePrinter 属性来获取计算机上所有已安装打印机的列表,并确定其中哪个打印机当前是活动打印机。

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 支持和反馈,获取有关如何接收支持和提供反馈的指南。