Printing CR report with ReportDocument class
I am using VS 2005 and have a VB 2005 app containing an embedded CR report and using a CR viewer. I want to print a report giving the user print options via a PrintDialog box and be able to run code if the user chooses to print or cancels the printing. I have not found a way to do this with the dialog box that appears when crViewer.PrintReport method is used.
My next options is to code a button that opens a PrintDialog box and uses the ReportDocument class to print the report. Documentation tells me a class is created that inherits from ReportDocument when an embedded report is created, so I am using that. My report is CaseHistory.rpt and the class is Public Class CaseHistory. Here is the code I am trying to use:
Dim rpt2 As CaseHistory = New CaseHistory
rpt2.Load("C:\CaseHistory.rpt")
rpt2.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Portrait
rpt2.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperLetter
rpt2.PrintOptions.PaperSource = CrystalDecisions.Shared.PaperSource.Auto
rpt2.PrintOptions.PrinterName = "\\SCRIBE\Printer3"
rpt2.PrintToPrinter(1, False, 0, 0)
Problems I have encountered: I get a fatal execution engine error when the app gets to setting PaperOrientation, Size, Source and PrinterName. When I comment these out and get to PrintToPrinter, the app hangs with no messages and no report printed. I have to use Task Manager to shut it down. What's wrong here?
With aching, bruised and battered head,
Steve

