Printing Reports To A Printer Other Then one specified with report Switching Portrait / Landscape 
Author Message
 Printing Reports To A Printer Other Then one specified with report Switching Portrait / Landscape

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.

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. Crystal Reports ANd VB 6.0 Printing reports using CRPEAUTO Object, specifying paper orientation problem

2. Reports are printed on more than one page on HP Deskjet printer

3. Printing multiple reports as one report

4. One Report To Multiple Trays Of One Printer

5. VB6-Data Reports ->Show one specified record ?

6. Q: Printing report on non-default printer w/o user selecting printer

7. CR 8.5 - Switching from portrait in a report to landscape in a sub-report

8. Printing a report when no printer or print drivers are installed on the server

9. printing without crystal report or data report for non data base reports

10. Crystal Reports Printing to the not-default printer sq Landscape printing

11. Specifying Print Pages in Crystal Reports

12. Print a report via crystal reports without print dialogue displaying

 

 
Powered by phpBB® Forum Software