Topic: Help with printing... Posted: 14 Sep 2007 at 10:23am
Hello, this problem has haunted me for a long time, and I'm beginning to get nervous...
I'm running on windows XP, using VB 2005 and Crsytal Reports XI.
Well, I have a CrystalReportViewer embedded in a form, and I want that the user has two choices: see the report, or just send it to the printer... The CrystalReportViewer has a printReport method, but the problem is that it asks for confirmation of wich printer use.
I want to avoid this, just send it to the default printer, without prompting the user the print dialog.
Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Posted: 14 Sep 2007 at 12:50pm
I think there was a post about this a month ago. I forget what the answer was. You should search the forum to see comes up.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
Thanks, well, I think this will do... I paste the code here so someone can have the answer:
Dim rpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim prnOpts As CrystalDecisions.CrystalReports.Engine.PrintOptions
Dim ps As New PrinterSettings
'here I put the report on display and all that
repOPViewer.CrystalReportViewer1.SelectionFormula = "{tblObras.Obr_intIdObra} = " & ordenProd.txtIdObra.Text
repOPViewer.CrystalReportViewer1.RefreshReport()
repOPViewer.Show()
'here I begin to print to the default printer
rpt = repOPViewer.CrystalReportViewer1.ReportSource
prnOpts = rpt.PrintOptions
prnOpts.PrinterName = ps.PrinterName
rpt.PrintToPrinter(1, True, 0, 0)
repOPViewer.Close()
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum