?
Solved

Crystal Reports Printing

Posted on 2005-03-29
3
Medium Priority
?
203 Views
Last Modified: 2010-04-23
Hi

When I call the PrintReport method of the CrystalReportViewer in VB.NET 2003, it brings up the Windows Print dialog box (the one where you can select the printer and so on). How can I make it so that it just prints, to the default printer if necessary, without bringing up the Windows Print dialog? I need to do this because I wrote a software which has to perform batch printing of many Crystal Reports, and the user should'nt have to click "Print" every time.

Thanks for your support
0
Comment
Question by:SETP
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 27

Accepted Solution

by:
planocz earned 1000 total points
ID: 13654057
This might work for you.
I use this to print with the Acrobat 6.0 Reader......


'MODULE

Imports System.IO

    Public Function InitializeDefaultPrinter()
        ' Set the specified printer to the default printer for this program. Return
        ' true if the printer was found.

        Dim objprinter As PageSettings = New PageSettings
        Dim strname = objprinter.PrinterSettings.PrinterName

        InitializeDefaultPrinter = strname
    End Function
    Public Sub PrintReports()
        Cursor.Current = Cursors.WaitCursor
        ' Dim frm As New frmCrDates

        Dim regKey As RegistryKey
        Dim sPrinterDriver As String
        Dim sPrinterPort As String
        Dim myProcess As New Process
        Dim sDefaultPrinter As String
        Dim keyValue As String

        'To get the Printer driver...
        sDefaultPrinter = InitializeDefaultPrinter()
        'Added 10-25-2004 for server printers
        'If sDefaultPrinter.StartsWith("\") Then
        '    sDefaultPrinter = sDefaultPrinter.Substring(2)
        'End If
        keyValue = "Software\\Microsoft\\Windows NT\\CurrentVersion\\Print\\Printers\\" & sDefaultPrinter
        regKey = Registry.LocalMachine.OpenSubKey(keyValue, False)
        sPrinterDriver = regKey.GetValue("Printer Driver", 0)
        sPrinterPort = regKey.GetValue("Port", 0)
        regKey.Close()

        Try
            Dim di As New DirectoryInfo(sAppPath & sReportPath & "Acrobat\")
            Dim fi As FileInfo() = di.GetFiles()
            Dim fiTemp As FileInfo
            Dim i As Short
            Dim j As Short = 20
            'Run this EXE to print files sReader = "C:\Program Files\Adobe\Acrobat 6.0\Reader\AcroRd32.exe"
            Dim startInfo As New ProcessStartInfo(sReader)
            startInfo.WindowStyle = ProcessWindowStyle.Hidden
            startInfo.CreateNoWindow = True
            For Each fiTemp In fi
                startInfo.Arguments = "/t """ & fiTemp.FullName & """ """ & sDefaultPrinter & """ """ & sPrinterDriver & """ """ & sPrinterPort & """"
                startInfo.UseShellExecute = False
                myProcess.Start(startInfo)
                '
                'Use delay to wait for printer to print files in 30 file units
                i += 1
                Select Case i
                    Case j
                        delay(2000)  '2 mins.
                        j += 30
                End Select
            Next fiTemp
        Catch Exp As Exception
            MsgBox(Exp.Message & "   in Print Report Procedure", MsgBoxStyle.Critical, "General Error")
        End Try
        Cursor.Current = Cursors.Default
    End Sub
0
 

Author Comment

by:SETP
ID: 13662329
WOW! That's quite a solution you poseted there! Will the client need Acrobat Reader installed?
0
 
LVL 27

Expert Comment

by:planocz
ID: 13662406
Yes it is Free from Adobe.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question