The Printer object enables you to communicate with a system printer (initially the default system printer).
Printer
The Printer object controls the current selected printer through its properties and methods. By default, the Printer object controls the default system printer, but this can be changed by using the CommDlg methods ShowPageSetup and ShowPrint, which allows the user to select a printer, or by using the SetPrinterByName command.
SetPrinterByName invokes a hidden Set Printer = statement.
After selecting a printer with ShowPrint, the CommDlg object must be assigned to the Printer object (see example). Once the Printer object is setup the printer options can be adjusted using the properties and methods. However, this doesn't mean that the printer itself is initialized. To initialize the printer and select the color, font, and sizes, the print job must be started. The initialization occurs when StartDoc is executed or when Lprint is invoked. Lprint ""; initializes the printer without moving the current output position (for an example see PrintForm).
Note - To both read and write the properties of an individual printer, you must first make that printer the default printer for the application.
// Select a printer and use landscape mode.
OpenW 1
Ocx CommDlg cd
cd.ShowPrint // Open Printer dialog box
Set Printer = cd // change Printer object
Printer.StartDoc "Test" // initialize
Printer.Orientation = 1 // portrait mode
Output = Printer // change output
Printer.StartPage
FontName = "courier new"// current output
FontSize = 72
Print "Hello"
Printer.EndPage
Printer.Orientation = 2 // landscape
Printer.StartPage
Print "Hello"
Printer.EndPage
Printer.EndDoc
Output = Win_1
BackColor | BkColor | CurrentX | CurrentY | DefHeight | DefLeft | DefTop | DefWidth | DeviceName | dmCollate | dmColor | dmCopies | dmPaperBin | dmPaperBinName | dmPaperLength | dmPaperSize | dmPaperSizeName | dmPaperSizeX | dmPaperSizeY | dmPaperWidth | dmQuality | dmYRes | Duplex | DrawMode | DriverName | Font | FontCount | FontBold | FontItalic | FontName | FontSize | FontStrikethru | FontTransparent | FontUnderline | Fonts | ForeColor | hDC | Height | Left | Name | Orientation | Page | PageWidth | PageHeight | PaperWidth | PaperHeight | PrintScroll | PrintWrap | PortName | ScaleHeight | ScaleLeft | ScaleMode | ScaleTop | ScaleWidth | Tag | Top | Width | Zoom
AbortDoc | EndDoc | EndPage | NewFrame | PaintPicture | Scale | ScaleX | ScaleY | SetFont | StartPage | TextHeight | TextWidth | TwipPerPixelX | TwipPerPixelY | TwipsPerPixelX | TwipsPerPixelY | PixelsPerTwipX | PixelsPerTwipY
To gather information about all the available printers on the system use the PrinterCount, PrinterName, and PrinterInfo properties of the App object.
Form, CommDlg, SetPrinterByName, PrinterCount, PrinterName, PrinterInfo
{Created by Sjouke Hamstra; Last updated: 21/10/2014 by James Gaite}