VB.Net method to print all available reports with a single button click
I have created a windows form with a crystal reports viewer, a combo box to select a report to view, and a button that I would like to (Print All Reports). The print button in the viewers toolbar will print the report currently being viewed. I want the button in my application to print all the reports without viewing them.
I have following code, but it throws an exception of type 'CrystalDecisions.Shared.CrystalReportsException' occurred in CrystalDecisions.CrystalReports.Engine.dll Additional information: Load report failed.
Imports CrystalDecisions.CrystalReports.Engine Imports CrystalDecisions.ReportSource Imports CrystalDecisions.Shared Imports CrystalDecisions.Windows.Forms Public Class frmReport Private Sub frmReport_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub cboReport_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboReport.SelectedIndexChanged Dim rptCustomer As New Customer Dim rptEmployee As New Employee Select Case cboReport.SelectedIndex Case 0 Me.CrystalReportViewer1.ReportSource = rptCustomer Case 1 Me.CrystalReportViewer1.ReportSource = rptEmployee End Select End Sub Private Sub btnPrintReports_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrintReports.Click Dim rptCustomer As New CrystalDecisions.CrystalReports.Engine.ReportDocument Dim rptEmployee As New CrystalDecisions.CrystalReports.Engine.ReportDocument rptCustomer.Load("Customer.rpt") rptEmployee.Load("Employee.rpt") rptCustomer.PrintToPrinter(1, False, 0, 0) rptEmployee.PrintToPrinter(1, False, 0, 0) End Sub End Class
I have searched and failed to find a solution. Any suggestions?
When you call CrystalDecisions.CrystalReports.Engine.ReportDocument's Load method you need to specify a path and a filename.
Also, have you granted NETWORK SERVICE permissions on Windows\Temp?