Solved

CrystalReport Printer Orientation

Posted on 2002-07-02
10
2,108 Views
Last Modified: 2012-05-04
Hi
I need to print my report (x.rpt) with landscape orientation, but when I set a printer, this orientation is ignored.
I have a report "a.rpt" with orientation defined as 2 (landscape).
In my app (cr is crystalreport object):
Dim oP As Printer

    cr.Destination = crptToWindow
    cr.ReportFileName = app.path & "\x.rpt"

    For Each oP In Printers
        If oP.DeviceName = cDestPrinter Then
            cr.PrinterName = oP.DeviceName
            cr.PrinterDriver = oP.DriverName
            cr.PrinterPort = oP.Port
            Exit For
        End If
    Next
           
    cr.Action = 1


Whe I try to comment line:
            cr.PrinterPort = oP.Port

orientation is OK, but printer is not selected.
What can I do to select printer and orientation without user interface ?
Alex
0
Comment
Question by:apsoft
10 Comments
 
LVL 3

Expert Comment

by:Elmo_
Comment Utility
Alex,

There are three different things that you can use to select the printer without user interface.  These are PRINTERNAME, PRINTERDRIVER, PRINTERPORT.  I have listed the details of these below.  

As for the Orientation of the report, you can not set this at run time.  This can only be set when you design the report.  This is why you cannot change this setting.

To print the report Set the DESTINATION property to crptToPrinter, and then use the ACTION property to print the report.

I have also listed the detalis of the DESTINATION and ACTION propertied for you.

Hope this helps,

Cheers,

Ed.




-----------------------------------
PrinterDriver

Description
Gets and sets the name of the printer driver that is to print the report.

Runtime Usage
[form.]CrystalReport.PrinterDriver[= DriverName$]
For example:
CrystalReport1.PrinterDriver = "Epson24.drv"
      
+Sets the printer driver to be the Epson 24 pin driver;
Remarks
The PrinterDriver, PrinterName, and PrinterPort properties work together to define the printer that the report is to be sent to. All three properties must be set in order to define a new printer. If all three properties are not set, the printer defined in the report will be used. This may be the users default printer if none has been specified in the report.

Availability
DesignTime, Runtime


PrinterName

Description
Gets and sets the name of the printer that is to print the report.

Runtime Usage
[form.]CrystalReport.PrinterName[= PrinterName$]
For example:
CrystalReport1.PrinterName= "Epson LQ-850"
      
+Specifies the Epson LQ-850 printer;
Remarks
The PrinterDriver, PrinterName, and PrinterPort properties work together to define the printer that the report is to be sent to. All three properties must be set in order to define a new printer. If all three properties are not set, the printer defined in the report will be used. This may be the users default printer if none has been specified in the report.

Availability
Design time, Runtime


PrinterPort

Description
Sets the port for the specified printer.

Runtime Usage
[form.]CrystalReport.PrinterPort[= PortName$]
For example:
CrystalReport1.PrinterPort= "LPT1"
      
+Sets the printer port to LPT1;
Remarks
The PrinterDriver, PrinterName, and PrinterPort properties work together to define the printer that the report is to be sent to. All three properties must be set in order to define a new printer. If all three properties are not set, the printer defined in the report will be used. This may be the users default printer if none has been specified in the report.

Availability
Design time, Runtime


Action

Description
Action is the property that triggers the printing of the report.

Runtime Usage
[form.]CrystalReport.Action = 1
For example:
CrystalReport1.Action = 1
      
+prints the specified report.;
Remarks
Set the Action property to 1 in your procedure code (CrystalReport1.Action = 1) to print the report in response to a user event.

Availability
Runtime

Destination

Description
Specifies the destination to which your report is to be printed (Window, Printer, or File).

Runtime Usage
[form.]CrystalReport.Destination[= Destination%]
For example:
CrystalReport1.Destination = 0
      
+sends the specified report to a print window.;
Remarks
Select one of the following print destinations:
0       0 =Window (sends the report to a print window)      crptToWindow
1       1 =Printer (sends the report to a printer)      crptToPrinter
2       2 =File (prints the report to a disk file for printing at a later time or for importing into other applications. If you select this property, you will also have to set the PrintFileName and PrintFileType properties.)      crptToFile
3       3 =EMail via MAPI (sends the report to another person on your network via MAPI Email (Microsoft Mail). The report is attached to the EMail letter in the format specified by the PrintFileType property.)      crptMapi
      
Availability
Design time; Runtime
0
 

Author Comment

by:apsoft
Comment Utility
Elmo_, it is exactly what I was done.
I try to explain my situation again.
1. I have report with orientation setting to landscape.
2. I must print this report to printer selected programaticaly.
It is very simply, but -
My problem is:
When i set the printer (see my example below) (name, driver and port) the orientation defined in rpt file is ignored !
Can you try this example in your computer ?
Alex



0
 
LVL 3

Expert Comment

by:Elmo_
Comment Utility
Alex,

This should work for you.

I got it from the Crystal reports web site.  If you do not have crystal reports Tell me as you need to modules for this to work and they are supplied with the crystal reports installation.

http://support.crystaldecisions.com/communityCS/FilesAndUpdates/orient16.zip

The Two Modules are Global.bas and crWrap.bas

I can post them in full if required.  

This code should enable you to change everything you need.

Cheers,

Ed.
0
 

Author Comment

by:apsoft
Comment Utility
Elmo_, you send me VB example with "The Crystal Report Engine Automation Server" (or crAPLI) development tool, but I have "Crystal ActiveX Control" on each form in my application.
It is imposible to change this development tool in each place in my app (this is very big app).

Can you help me with "Crystal ActiveX Control" ?
My Seagate Crystal Reports version is: 7.0.0.0
MS VB6 with SP 5.
Alex
0
 
LVL 3

Accepted Solution

by:
Elmo_ earned 200 total points
Comment Utility
Alex,

The only answer to your question then is that there is no way you can control set the page orientation when you print a Crystal Report.  It should hold the page layout that you supplied when generating the report.

The only other thing that it could be is that you have checked the "Default Values" box within the printer settings on your crystal Report.

Bar this I do not think that it is possible to Set the Page Orientation using the Visual Basic Crystal ActiveX Control.

If you want control like this you will need to use the Crystal Report APIs that are define in the link provided.

Cheers,

Ed.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:apsoft
Comment Utility
Ok, but why crystal reports change orientation of my report when i changing the printer port ?
May be it is possible to prevent this behaviour ?
Alex
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
I suspect your user has PORTRAIT selected as the default for the printer.  Change the printer default and it should work.

I have CR8 and it has a PAPERORIENTATIOIN option in CR.  Use crLandscape.

cr.PaperOrientation = crLandscape

If you don't specify that the value used is crDefualtPaperOrientation which probably means use the default for the printer.

good luck
mlmcc
0
 
LVL 3

Expert Comment

by:Elmo_
Comment Utility
Alex,

Any update here?

Cheers,

Ed.
0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
Hi apsoft,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept Elmo_'s comment(s) as an answer.

apsoft, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 

Expert Comment

by:SpideyMod
Comment Utility
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now