Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot print reports in landscape orientation 2

Status
Not open for further replies.

sdfgsghdyhyer

Programmer
Apr 22, 2004
5
SK
Hello,

I set my report to print landscape in its printer setup. I use VB6 and CR8. When I`m printing without setting printer port, driver and name {with default options) everything runs.
But Now I must switching 2 printers from VB - so setting printer port, driver and its name. After that my report is in portrait mode and I can`t force it to landscape mode. I`m surprised that I can`t use some method of Crystal report object as PAPER ORIENTATION. I tried crDEVMODE modul with windows API functions, but i dont know how to handle subreports.

Any Idea?

Thanx a lot.

Andree
 
Here's some code from a previous thread of mine. Basically, you want to get the report's orientation before calling the PrinterSetup method, pick the printer, then reset the orientation.
Code:
Private Sub Viewer_PrintButtonClicked(UseDefault As Boolean)

    UseDefault = False  'Don't use the default printer
    
    'CRPaperOrientation and CRPaperSize are Enumerated type _
        members of the CRAXDRT library
    Dim cOrientation As CRPaperOrientation
    Dim cSize As CRPaperSize
    
    'Get the report's current orientation and paper size
    cOrientation = crxRpt.PaperOrientation
    cSize = crxRpt.PaperSize
    
    crxRpt.PrinterSetup Me.hWnd     'Call the Printer Setup dialog

    'Loop through the Printers collection to ensure the correct _
        printer gets set for the report
    Dim p As Printer
    For Each p In Printers
        If p.DeviceName = crxRpt.PrinterName Then
            crxRpt.SelectPrinter p.DriverName, p.DeviceName, p.Port
            Exit For
        End If
    Next p

    'Reset the report's PaperOrientation and PaperSize properties _
        to override the "new" printer's defaults
    crxRpt.PaperOrientation = cOrientation
    crxRpt.PaperSize = cSize
    
    'Prompt the user for page numbers, copies, etc.
    crxRpt.PrintOut True, 1
    
    'To print directly to the printer, comment out the above line, _
        and uncomment the next line
    'crxRpt.PrintOut False, 1

End Sub
-dave
 
Thanx vidru,

but i can't access Crystal report object properities as PaperOrientation or PaperSize - that is why i'm surprised (I have CR 8.0.1.0)

Maybe I can do something with Printers collation and its ORIENTATION property - but i can only read this property .... I hope still is other way .... maybe I do something wrong.

Thanx.
 
How are you calling the reports? Are you using the OCX (Crystal Report Control)?

And do you have the Developer version of CR 8?

-dave
 
Yes vidru, i have Developer version of CR 8 and I'm using OCX (CRC). And I'm connecting to SQL server via ODBC data source.

Thanx for your help.

Andree.
 
Andree,

This might be a good time to abandon the OCX control, and move to the RDC (Report Designer Component). I can't find any way to reset the paper orientation using the OCX. That doesn't mean there isn't one, but after testing and looking through the OCX help files, I don't see how it can be done.

The code I posted above uses the CRAXDRT object library (Crystal Reports 8.x ActiveX Designer Run Time Library). By using it in conjunction with the Crystal Reports Viewer Control (crviewer.dll), you have much more control of your reports.

Here's a link to a pdf that describes how to move from the OCX to the RDC, and what the advantages are:

In Page 12 of the above document it says:
The RDC offers many advanced features that are not available in the OCX. As
Crystal Decisions releases future versions of Seagate Crystal Reports, new
features will only be available in the RDC.
Features exclusive to the RDC include:

Printer options - set paper orientation and paper size, set duplex printing
options and paper source, display a Window standard Printer Setup dialog
box.
-dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top