PRB: Multiple Visual Basic Printouts Are Not the Same (173074)
The information in this article applies to:
- Microsoft Visual Basic Learning Edition for Windows 5.0
- Microsoft Visual Basic Learning Edition for Windows 6.0
- Microsoft Visual Basic Professional Edition for Windows 5.0
- Microsoft Visual Basic Professional Edition for Windows 6.0
- Microsoft Visual Basic Enterprise Edition for Windows 5.0
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
This article was previously published under Q173074 SYMPTOMS
When you print what should be identical copies of the same print job, the
pages do not print the same. Different fonts, text in the wrong place, and
multiple blank pages are typical.
CAUSE
The primary cause of differences between print jobs is that the Visual
Basic Printer Object is not fully reset by the EndDoc method. The
values of the ScaleMode and a few other properties are inherited by
subsequent documents unless the application is restarted. The most common
source of problems is that new values are assigned to the Scale properties:
(ScaleMode, ScaleHeight, ScaleLeft, ScaleTop, and ScaleWidth). These
properties are not reset by the NewPage or EndDoc method and should be
reset by the programmer to ensure correct behavior.
Another cause is that changing some printer properties changes other
printer properties in ways that are not necessarily intuitive. Changing the
ScaleMode property affects the other Scale properties and CurrentX/Y, which
need to be converted to the new coordinate system. Similarly, changing the
ScaleLeft/Top properties affects the values of CurrentX/CurrentY,
respectively.
RESOLUTION
To work around this behavior, reset the ScaleMode and other properties to
their original values. The code below enumerates all of the properties of
the printer object and displays their values on the Immediate pane. During
your debug cycle, call the code before each print job and compare the
results. You can then modify your code to correctly reset the appropriate
property values:
Sub PrntProp()
Debug.Print "ColorMode ", Printer.ColorMode
Debug.Print "Copies ", Printer.Copies
Debug.Print "CurrentX ", Printer.CurrentX
Debug.Print "CurrentY ", Printer.CurrentY
Debug.Print "DeviceName ", Printer.DeviceName
Debug.Print "DrawMode ", Printer.DrawMode
Debug.Print "DrawStyle ", Printer.DrawStyle
Debug.Print "DrawWidth ", Printer.DrawWidth
Debug.Print "DriverName ", Printer.DriverName
Debug.Print "Duplex ", Printer.Duplex
Debug.Print "FillColor ", Printer.FillColor
Debug.Print "FillStyle ", Printer.FillStyle
Debug.Print "Font.Bold", Printer.Font.Bold
Debug.Print "Font.Charset", Printer.Font.Charset
Debug.Print "Font.Italic", Printer.Font.Italic
Debug.Print "Font.Name", Printer.Font.Name
Debug.Print "Font.Size", Printer.Font.Size
Debug.Print "Font.Strikethr "; Printer.Font.Strikethrough
Debug.Print "Font.Underline "; Printer.Font.Underline
Debug.Print "Font.Weight", Printer.Font.Weight
Debug.Print "hDC ", Printer.hDC
Debug.Print "Height ", Printer.Height
Debug.Print "Orientation", Printer.Orientation
Debug.Print "Page ", Printer.Page
Debug.Print "PaperBin ", Printer.PaperBin
Debug.Print "PaperSize ", Printer.PaperSize
Debug.Print "Port ", Printer.Port
Debug.Print "PrintQuality", Printer.PrintQuality
Debug.Print "RightToLeft", Printer.RightToLeft
Debug.Print "ScaleHeight", Printer.ScaleHeight
Debug.Print "ScaleLeft ", Printer.ScaleLeft
Debug.Print "ScaleTop ", Printer.ScaleTop
Debug.Print "ScaleWidth ", Printer.ScaleWidth
Debug.Print "ScaleMode ", Printer.ScaleMode
Debug.Print "TrackDefault", Printer.TrackDefault
Debug.Print "TwipsPerPixelX"; Printer.TwipsPerPixelX
Debug.Print "TwipsPerPixelY"; Printer.TwipsPerPixelY
Debug.Print "Width ", Printer.Width
Debug.Print "Zoom ", Printer.Zoom
End Sub
Modification Type: | Major | Last Reviewed: | 5/13/2003 |
---|
Keywords: | kbprb KB173074 |
---|
|