Export (0) Print
Expand All

Printer Object

Office 2007
A Printer object represents a printer installed on your computer.

Version Information
 Version Added:  Publisher 2007

Remarks

Many of the properties, such as PaperSize, PaperSource, and PaperOrientation, of the Printer object correspond to the settings in the Print Setup dialog box (File menu) in the Microsoft Office Publisher user interface .

The collection of all the printers installed on your computer is represented by the InstalledPrinters collection.

Example

The following Microsoft Visual Basic for Applications (VBA) macro shows how you can use the PrinterName and IsActivePrinter properties of the Printer object to get a list of all the installed printers on the computer, determine which of them is currently the active printer, and get some of the settings of the active printer. The macro displays the results in the Immediate window.

Visual Basic for Applications
Public Sub Printer_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"
            Debug.Print "Paper size is ", pubPrinter.PaperSize
            Debug.Print "Paper orientation is ", pubPrinter.PaperOrientation
            Debug.Print "Paper source is ", pubPrinter.PaperSource
        End If
    Next

End Sub



Community Additions

ADD
Show:
© 2014 Microsoft