Writing Code
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Writing Code
Message Icon Topic: Help with printing... Post Reply Post New Topic
Author Message
danmir
Newbie
Newbie
Avatar

Joined: 15 Jul 2007
Location: Mexico
Online Status: Offline
Posts: 6
Quote danmir Replybullet 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.

Please Help!!
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet 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>
IP IP Logged
danmir
Newbie
Newbie
Avatar

Joined: 15 Jul 2007
Location: Mexico
Online Status: Offline
Posts: 6
Quote danmir Replybullet Posted: 26 Sep 2007 at 11:38am
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

        repOPViewer.CrystalReportViewer1.ReportSource = repOPViewer.OPIntApo1
       
'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()


Enjoy!!
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
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



This page was generated in 0.016 seconds.