Crystal Reports ANd VB 6.0 Printing reports using CRPEAUTO Object, specifying paper orientation problem 
Author Message
 Crystal Reports ANd VB 6.0 Printing reports using CRPEAUTO Object, specifying paper orientation problem

Hi There,

I have tried for hours to solve this one.
Using Crystral Reports Pro 6.0 and VB5.0 Enterprise

To print a report to a printer other then the one specified within the
report. I use the CRPEAUTO object for generating and printing reports. I do
not seem to be able to specify the layout of the report ie Landscape or
Portrait. The code is as follows
 This has been trimmed to show just the WORKS ORDER printing.

Even though I set the paper orientation to 2 (landscape) it prints out in
Portrait. But if the printer specified by user is same as one within the
report, the report is printed out in Landscape. the differencc being that
the SelectPrinter method of the Report object does not get called if the
printer selected is the same as the one specified within the report.

appMain object is created with the following statement when the program is
started
    Set appMain = CreateObject("Crystal.CRPE.Application")

I could get around this by creating reports for each possible type of
Printer and using the relevant report with the selected printer but this to
me seems to be rather longwinded and untidy,not to mention,a nightmare to
maintain.

Thanks for your time and help in advance, any help or ideas will be
appreciated as I am stumped for the moment.

Lavesh.

Function PrintReport(sMode As String, iID As Long, bShowPS As Boolean, iDest
As Integer)

    Dim rptCur As CRPEAuto.Report
    Dim pgSetup As CRPEAuto.PageSetup
    Dim winOpt As CRPEAuto.PrintWindowOptions
    Dim prnInfo As CRPEAuto.PrinterInfo
    Dim winView As CRPEAuto.View
    SetupReportTables
    DoEvents
    On Error Resume Next
    sMode = Trim$(UCase$(sMode))
    If sMode = "WORKS ORDER" Then
        sRepFile = sReportPath & "\BCND1.RPT"
        iIDX = 0
        sSF = "({RPTORDERHDR.ORDERID})=" & Str$(iID)
        iOrient = 2
    Endif
   Set rptCur = appMain.OpenReport(sRepFile)
   Set pgSetup = rptCur.PageSetup
    With pgSetup
        .PaperSize = crPaperA4
        .PaperOrientation = iOrient
    End With
    rptCur.GroupSelectionFormula = sSF
    Set winOpt = rptCur.PrintWindowOptions
    Set prnInfo = rptCur.PrinterInfo
    If iDest = 0 Then
        With winOpt
            .HasPrintSetupButton = True
            .HasPrintButton = True
            .HasGroupTree = False
            .HasCancelButton = True
            .HasCloseButton = True
            .HasNavigationControls = True
            .HasZoomControl = True
            .HasPrintButton = True
            .HasPrintSetupButton = True
            .HasRefreshButton = True
        End With
        Set winView = rptCur.Preview
    Else
        If prnInfo.PrinterName <> arrPrinters(iIDX, 0) Or prnInfo.DriverName
<> arrPrinters(iIDX, 1) Or prnInfo.PortName <> arrPrinters(iIDX, 2) Then
            rptCur.SelectPrinter arrPrinters(iIDX, 1), arrPrinters(iIDX, 0),
arrPrinters(iIDX, 2)
        End If
        rptCur.PrintOut bShowPS
    End If
    If Err Then
        MsgBox "An Error Occurred While Printing " + sMode + " #" +
Str$(iID) + " !" + Chr$(13) _
        + "Error Code :" & Str$(Err), MB_ICONINFORMATION
        Err = 0
        PrintReport = False
        Exit Function
    End If
    PrintReport = True

End Function



Sat, 16 Feb 2002 03:00:00 GMT
 
 [ 1 post ] 

 Relevant Pages 

1. Printing report from Dynaset using Crystal Report and VB

2. print OLE object in my own VB App (not in Crystal report)

3. VB 6.0 reports vs. Crystal 6.0

4. using Crystal reports in VB 6.0 in HTML format

5. using Crystal reports in VB 6.0 in HTML format

6. Specifying Print Pages in Crystal Reports

7. Crystal Reports 6.0 RDC, new instance each report?

8. Problem with VB5-Crystal Report 6.0 Object Library(cpeaut32.dll)

9. Printing Access reports or using Access to print/preview reports

10. Need help printing LARGE reports with vb3.0 and Crystal Reports

11. Printing Crystal Reports report help needed

12. MSJetDB35.dll error with VB 6.0 SP3 and Crystal Reports 8.0


 
Powered by phpBB® Forum Software