
VB6 DataReport - Landscape printing problems
Quote:
> Go here:
> http://www.*-*-*.com/
Thanks, JBL. An easy solution to a pressing problem. It works great.
My code is posted below, if anyone is interested.
Dan
===============================
Option Explicit
' -----------------------------------------
' -- Printer functions to set orientation
' -- PageSet.dll must be registered in Windows and in VB6
' -- Examples for rptLandscape
'Private Sub cmdPrintPreview_Click()
' PrintPreview rptLandscape, vbPRORLandscape
'End Sub
'Private Sub cmdPrintAll_Click()
' PrintReport rptLandscape, vbPRORLandscape
'End Sub
' -- Use similar calls for vbPRORPortrait
' ------------------------------------------
Public Sub PrintPreview(rptReport As Object, intMode As Integer)
' -- Note: rptReport argument is set to 'Object' rather than
' 'DataReport' to get around a VB6 bug.
On Error GoTo errorhandler
SetPrinterOrientation intMode
rptReport.Show
On Error GoTo 0
Exit Sub
errorhandler:
MsgBox Err.Description
End Sub
' ------------------------------------------
Public Sub PrintAll(rptReport As DataReport, intMode As Integer)
' -- Prints the entire report without displaying the dialog
On Error GoTo errorhandler
SetPrinterOrientation intMode
rptReport.PrintReport False
On Error GoTo 0
Exit Sub
errorhandler:
MsgBox Err.Description
End Sub
' ------------------------------------------
Private Sub SetPrinterOrientation(intMode As Integer)
Dim obj As PageSet.PrinterControl
On Error GoTo errorhandler
Set obj = New PrinterControl
If intMode = 2 Then
obj.ChngOrientationLandscape
Else
obj.ChngOrientationPortrait
End If
On Error GoTo 0
Exit Sub
errorhandler:
MsgBox Err.Description
End Sub
' ------------------------------------------
Public Sub ResetPrinter()
' -- To reset the printer
' -- OK to call after a hardcopy print (e.g., PrintAll)
' -- Do NOT call immediately after a call to PrintPreview.
Dim obj As PageSet.PrinterControl
On Error GoTo errorhandler
Set obj = New PrinterControl
obj.ReSetOrientation
On Error GoTo 0
Exit Sub
errorhandler:
MsgBox Err.Description
End Sub