OrthoDocSoft
Programmer
Folks,
This has been working for months, but now, when it gets to a particular line, an error occurs (error 842, "printer error"), and the app crashes I have isolated the line that crashes to this one:
Here is the sub it is in:
Can anyone see why this is causing problems?
Do you think it is because of the new printer being installed? (I doubt it...)
Actually, I never print in landscape, so I'm thinking about just removing the portrait/landscape bit altogether, but I hate "cheating" like that.
Also, I could write an error handler which cancels the print without crashing the app, and I can do that I think.
Thanks,
Ortho
"you cain't fix 'stupid'...
This has been working for months, but now, when it gets to a particular line, an error occurs (error 842, "printer error"), and the app crashes I have isolated the line that crashes to this one:
Code:
Prn.Orientation = vbPRORPortrait
Here is the sub it is in:
Code:
Public Sub PrintPictureToFitPage(Prn As Printer, Pic As Picture, _
Optional ByVal strOrientation As String)
Const vbHiMetric As Integer = 8
Dim PicRatio As Double
Dim PrnWidth As Double
Dim PrnHeight As Double
Dim PrnRatio As Double
Dim PrnPicWidth As Double
Dim PrnPicHeight As Double
If strOrientation = "Landscape" Then
Prn.Orientation = vbPRORLandscape ' Wider than tall.
Else
Prn.Orientation = vbPRORPortrait ' Taller than wide.
End If
' Calculate device independent Width-to-Height ratio for picture.
PicRatio = Pic.Width / Pic.Height
' Calculate the dimentions of the printable area in HiMetric.
PrnWidth = Prn.ScaleX(Prn.ScaleWidth, Prn.ScaleMode, vbHiMetric)
PrnHeight = Prn.ScaleY(Prn.ScaleHeight, Prn.ScaleMode, vbHiMetric)
' Calculate device independent Width to Height ratio for printer.
PrnRatio = PrnWidth / PrnHeight
' Scale the output to the printable area.
If PicRatio >= PrnRatio Then
' Scale picture to fit full width of printable area.
PrnPicWidth = Prn.ScaleX(PrnWidth, vbHiMetric, Prn.ScaleMode)
PrnPicHeight = Prn.ScaleY(PrnWidth / PicRatio, vbHiMetric, _
Prn.ScaleMode)
Else
' Scale picture to fit full height of printable area.
PrnPicHeight = Prn.ScaleY(PrnHeight, vbHiMetric, Prn.ScaleMode)
PrnPicWidth = Prn.ScaleX(PrnHeight * PicRatio, vbHiMetric, _
Prn.ScaleMode)
End If
' Print the picture using the PaintPicture method.
Prn.PaintPicture Pic, 0, 0, PrnPicWidth, PrnPicHeight
End Sub
Can anyone see why this is causing problems?
Do you think it is because of the new printer being installed? (I doubt it...)
Actually, I never print in landscape, so I'm thinking about just removing the portrait/landscape bit altogether, but I hate "cheating" like that.
Also, I could write an error handler which cancels the print without crashing the app, and I can do that I think.
Thanks,
Ortho
![[lookaround] [lookaround] [lookaround]](/data/assets/smilies/lookaround.gif)