代表所有 印表機 物件的集合,每個物件都代表電腦上安裝的其中一個印表機。
註解
若要讓使用者選擇用來列印出版物的印表機,您可以逐一查看 InstalledPrinters 集合以取得電腦上安裝的所有印表機名稱清單。
InstalledPrinters 集合的預設屬性為 Item 。
範例
下列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 支援與意見反應。