Link to home
Start Free TrialLog in
Avatar of Dee
DeeFlag for United States of America

asked on

Select printer tray for Crystal Report

I am using the following vb.net code to print a crystal report (VS2008) and select the printer tray.  No matter what paper source option I select, it always prints from the default tray.  

       Dim cr As New ReportDocument
        cr.Load(sReportPath)
        cr.SetParameterValue("PO", "DP000238690")
        cr.PrintOptions.PaperSource = PaperSource.EnvManual
        cr.PrintToPrinter(1, True, 1, 1)
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Avatar of Mike McCracken
Mike McCracken

Was the report built with that printer as the default?

Was the report built as an envelope?

mlmcc
Avatar of Dee

ASKER

I'm using the default printer.

The report is not an envelope .... I tried every possible option to change trays.  That just happened to be the last option I tried when I copied and pasted my code.  No matter what I select, it always prints to the default tray.

cr.PrintOptions.PaperSource = PaperSource.Lower
        cr.PrintToPrinter(1, False, 1, 1)

        cr.PrintOptions.PaperSource = PaperSource.Middle
        cr.PrintToPrinter(1, False, 1, 1)
Avatar of Dee

ASKER

I just tried changing the tray in the printer settings and saving it with the report design.  Why doesn't that work?  No matter what I select, it still prints to the default tray also.
I found on some of my reports that I had to set the printer to default to landscape.  It seems Crystal could change a report back to portrait but it could change it to landscape.

Does the tray have the correct paper in it?
I asked about envelope because you were changing it to envmanual

mlmcc
Avatar of Dee

ASKER

The printer has the correct paper in it.  I am not printing envelopes ... disregard that ... that was just one of the options that I tried in trying to get it to switch trays.  I tried all options ... PaperSource.Lower, PaperSource.Middle, etc.  All trays are loaded with the correct size paper - letter size.

I changed the printer to default to landscape.  No help.
Don't change to landscape unless you want to print landscape that was just an example of what i had to do.

Perhaps changing the printer to default to the tray you want will work.

mlmcc
Are you using the VS2008 version of Crystal?

You might look at this thread in the Crystal forums
http://forums.sdn.sap.com/thread.jspa?threadID=1837625

mlmcc
Avatar of Dee

ASKER

If I change the printer to default to the correct tray, it works, but then everything else prints to that tray.  I have 2 reports that I need to print from different trays, so I need to change it programmatically or  save it in the report design.

I am using VS2008 version of Crystal.  I'll take a look at the links.
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dee

ASKER

The links were no help.

"It is a problem that has been an issue with Crystal for some time"
         Neither was that :(
I know that wasn't much help but it may explain why it does work.  Part of the problem is how the printers set the tray and when it gets done.

I wonder if you can get the application to set the default printer tray based on the report that is being run.

mlmcc
Avatar of Dee

ASKER

How so?  Isn't that what I'm already trying to do here:

Dim cr As New ReportDocument
        cr.Load(sReportPath)
        cr.SetParameterValue("PO", "DP000238690")
        cr.PrintOptions.PaperSource = PaperSource.Lower
        cr.PrintToPrinter(1, True, 1, 1)
No, you are changing the printer tray for the report.  I mean the actual printer so that anything that prints will then go to that tray.

I don't know the printer codes so may need to get some other expert in.

mlmcc
Avatar of Dee

ASKER

Ok, I found this code that is supposed to change the default printer tray, but I can't get it to work.  Maybe I need to post a new question.
-----------------
        Dim Printdoc As New Printing.PrintDocument
        Dim SetPage As New System.Drawing.Printing.PageSettings

        With SetPage
            .PaperSource = Printdoc.PrinterSettings.PaperSources(0)
        End With
        Printdoc.DefaultPageSettings = SetPage
No need for a new question.  I'll try to get a hardware/printer expert
What printer manufacturer?

mlmcc
Avatar of Dee

ASKER

HP LaserJet 4345 mfp PCL 6

Thanks
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dee

ASKER

I found this code works in vb6 and crystal 10 for hp printer.

Report.PaperSource = 263     '263 = tray 5 '262 = tray 4 '261 = tray 3 '260 = tray 2
Report.PrintOut False

Why is everything so hard in .net?  I may end up coding this in vb6.

Thanks byundt.  I may try your suggestion first.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial