130 likes | 155 Views
Printing. The Printers Collection. We have seen that there is a Forms collection And a collection of objects in each Form frmMyForm There is also a Printers Collection. You can find out printer properties:. ‘Print printer names on the form For Each myPrinter In Printers
E N D
The Printers Collection • We have seen that there is a Forms collection • And a collection of objects in each Form frmMyForm • There is also a Printers Collection
You can find out printer properties: ‘Print printer names on the form For Each myPrinter In Printers Form1.Print myPrinter.DeviceName Next
You can find out how many Printers exist: frmMyForm.print Printers.Count
But remember… • Arrays usually start at 0 • So your printers collection is 0-2, not 1-3 EXAMPLES OF PROPERTIES: Printers(0).CurrentX Printers(1).Port Printers(2).PrintQuality
Very Useful Properties • ScaleModevbTwips, vbPixels, vbInches, vbCharacters • CurrentX, CurrentY • Orientation • ColorMode • You can actually choose the printer that has the needed properties
Choosing the Printer: • Set Printer = Printers(1) • Not needed if you are using the default printer
“Building” Printer Output • The printer doesn’t just start printing • Issue NewPage or EndDoc command NewPage is also useful for….Making a New Page!
Controlling Margins • ScaleMode = vbCharacters • ScaleLeft = howManyCharacters • ScaleTop = CharFromTop • ScaleHeight = 10 • ScaleWidth = 10
Printing at a certain spot • CurrentX • CurrentY
2Things to remember • Warn your users prior to printing • Provide Error-Trapping code (listing 13.6)
Make a print Module • Since many programs will print, you may wish to make a reusable print module.
Printing Graphics • Use AutoRedraw=True when printing the current status of a form. • frmMyForm.PrintFormEasy way to print graphics (the form) • Can print lines, shapes, graphics (next subject).