Professional Documents
Culture Documents
There are several ways to place text and graphics on the Printer object. To print with the Printer object, do any of the following:
z Assign the specific member of the Printers collection to the Printer object if you want to print to a printer other than the default printer.
z Print the contents of the Printer object with the NewPage or EndDoc method.
If the TrackDefault property is True and you change the default printer in the Windows Control Panel, the Printer object property values will reflect the properties of the
new default printer.
You cannot change some properties in the middle of a page once a property has been set. Changes to these properties will only affect subsequent pages. The following
statements show how you can print each page using a different print quality:
For pageno = 1 To 4
Printer.PrintQuality = -1 * pageno
Printer.Print "The quality of this page is"; pageno
Printer.NewPage
Next
Print quality values can range from – 4 to – 1, or a positive integer corresponding to the print resolution in dots per inch (DPI). For example, the following code would set
the printer’s resolution to 300 DPI:
Printer.PrintQuality = 300
For More Information For information on the Printer object properties, see the appropriate property in the Language Reference.
Note The effect of Printer property values depends on the driver supplied by the printer manufacturer. Some property settings may have no effect, or several different
property settings may all have the same effect. Settings outside the accepted range may or may not produce an error. For more information on specific drivers, see the
manufacturer’s documentation.
Scale Properties
The Printer object has these scale properties:
z ScaleMode
z Zoom
The ScaleLeft and ScaleTop properties define the x- and y-coordinates, respectively, of the upper-left corner of a printable page. By changing the values of ScaleLeft and
ScaleTop, you can create left and top margins on the printed page. For example, you can use ScaleLeft and ScaleTop to center a printed form (PFrm) on the page using
these statements:
Many printers support the Zoom property. This property defines the percentage by which output is scaled. The default value of the Zoom property is 100, indicating that
output will be printed at 100 percent of its size (actual size). You can use the Zoom property to make the page you print smaller or larger than the actual paper page. For
example, setting Zoom to 50 makes your printed page appear half as wide and half as long as the paper page. The following syntax sets the Zoom property to half the
size of the default Printer object:
Printer.Zoom = 50
Printer.CurrentX = 0
Printer.CurrentY = 0
You can also use the TextHeight and TextWidth methods to position text on the Printer object. For more information on using these text methods, see "Displaying Print
Output at a Specific Location" earlier in this chapter.
z The output of graphics methods applied directly to the form, including the Print method.
The extent to which you recreate these elements on the Printer object depends on your application and how much of the form you need to print.
For example, the following procedure uses the PaintPicture method to print a form or control’s Picture property to any output object, such as a printer or another form:
You then call this procedure and pass it the source and destination objects:
For More Information For more information, see "Print Method," "Line Method," "Circle Method," "Pset Method," or "PaintPicture Method" in the Language Reference.
Note Visual Basic automatically calls EndDoc if your application ends without explicitly calling it.
Sub PrintOrNot()
Printer.Print "This is the first line to _
illustrate KillDoc method"
Printer.Print "This is the second line to _
illustrate KillDoc method"
Printer.Print "This is the third line to _
illustrate KillDoc method"
If vbNo = MsgBox("Print this fine document?", _
vbYesNo) Then
Printer.KillDoc
Else
Printer.EndDoc
End If
End Sub
If the operating system’s Print Manager is handling the print job, the KillDoc method deletes the entire job you sent to the printer. However, if the Print Manager is not
Note You cannot use the KillDoc method to terminate a print job that was initiated with the PrintForm method.