469,267 Members | 1,085 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,267 developers. It's quick & easy.

Print Report directly to Printer

Hi,
I want to print crystal report directly to printer using vb.net application without any dialog box. how can i achieve this?

CrystalReportViewer1.ReportSource = System.Environment.CurrentDirectory & "\MiniStatement.rpt"
'CrystalReportViewer1.Show()
CrystalReportViewer1.PrintReport()

Thanks:
Danish Majid
May 21 '07 #1
12 21989
kenobewan
4,871 Expert 4TB
Please search the site, there are a few examples of this.
May 21 '07 #2
I search the site but the examples here are for printing the text file to printer and i unable to find any query to print crystal report directly to printer.
Any help?
May 21 '07 #3
Motoma
3,237 Expert 2GB
I search the site but the examples here are for printing the text file to printer and i unable to find any query to print crystal report directly to printer.
Any help?
Most Crystal Reports Reports have a PrintToPrinter member to call.
May 21 '07 #4
Hi Danishce,
You can try PrinttoPrinter Method.
write this code in any button click event

Expand|Select|Wrap|Line Numbers
  1.  /* Print the report. Set the no. of copies, collate (false or true), startPageN and endPageN . set startPageN and endPageN parameters to 0 to print all pages.*/
  2.                         reportobject.PrintToPrinter(1, true, 0, 0);
Before that bind the report to the report object.
May 22 '07 #5
Thanks all for helping me but still i can not find PrinttoPrinter method in the crystalreportviewer dropdownlist inside my vb.net application.can you guide me step-by-step how to do this?
Report name =rptStatement.rpt
Crystal Report Control Name=CrystalReportViewer1
Crystal Report Version=9.2.0.448
Visual Studio .NET 2003=vb.net

//Code
CrystalReportViewer1.ReportSource = "rptStatement.rpt"
CrystalReportViewer1.PrintReport()

but when i use CrystalReportViewer1.PrinttoPrinter() method it does not appear in properties & gives error.

Please help me what i missed here?
Thanks
May 22 '07 #6
using the code below the PrinttoPrinter method appears
Dim obj As New CrystalDecisions.CrystalReports.Engine.ReportDocum ent
obj.PrintToPrinter(1, True, 0, 0)
but gives the following error :
error=D:\rptStatement.rpt Cannot find custom tool 'CrystalDecisions.VSDesigner.CodeGen.ReportCodeGen erator' on this system.

and also how can i set the name and location of report?
May 22 '07 #7
Motoma
3,237 Expert 2GB
using the code below the PrinttoPrinter method appears
Dim obj As New CrystalDecisions.CrystalReports.Engine.ReportDocum ent
obj.PrintToPrinter(1, True, 0, 0)
but gives the following error :
error=D:\rptStatement.rpt Cannot find custom tool 'CrystalDecisions.VSDesigner.CodeGen.ReportCodeGen erator' on this system.

and also how can i set the name and location of report?
Take a look at this link for a demonstration on report printing.
May 22 '07 #8
MyReport.PrintToPrinter(1,False,0,0)
In the above code, how i create report object named MyReport because when i create object the report name does not appear.Report name is "RptStatement.rpt"
dim MyReport as new RptStatement
it gives the error.
Please help me out on how i create report object or can i miss any referenece to report?
May 23 '07 #9
Just Write

Dim cr as new crystalreport1
cr.printtoprinter(1,false,1,1)


That's all Cheers
May 23 '07 #10
Thanks All for helping me out,I have finally succeeded using following code:
Dim obj As New CrystalDecisions.CrystalReports.Engine.ReportDocum ent
Dim m_rptname As String
m_rptname = System.Environment.CurrentDirectory & "\MiniStatement.rpt"
obj.Load(m_rptname)
obj.PrintToPrinter(1, True, 0, 0)
May 24 '07 #11
Motoma
3,237 Expert 2GB
Thanks All for helping me out,I have finally succeeded using following code:
Dim obj As New CrystalDecisions.CrystalReports.Engine.ReportDocum ent
Dim m_rptname As String
m_rptname = System.Environment.CurrentDirectory & "\MiniStatement.rpt"
obj.Load(m_rptname)
obj.PrintToPrinter(1, True, 0, 0)
I am glad you have found a solution to your problem. Come back any time you have a question.
May 24 '07 #12
Hi,

Good to hear about your sucess
But I didn't get sucess in my problem
My problem is to export the report in .txt format in vb.net 2003 environment
this project is pending from about 1yr
Please help me

Regards
Aatish
May 24 '07 #13

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Khalid Hussain | last post: by
5 posts views Thread by Tony Dong | last post: by
1 post views Thread by =?Utf-8?B?SmJhcmJlcg==?= | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.