not have the Print Dialog pop up when I use printreport to send to printer

Posted on 2009-02-24
Last Modified: 2012-05-06
I'm using Visual basic 2008 and  I would like to know if there's a way to not have the Print Dialog pop up when I use printreport to send to printer.
Private Sub frmRapport_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


        Me.CrystalReport31.SetParameterValue(0, My.Settings.NoContrat.ToString)

        If not PrintDocument1.PrinterSettings.IsValid = False Then



        End If

    End Sub

Open in new window

Question by:sylvainhotte
    LVL 96

    Accepted Solution

    You really didn't believe me.


    Public Overridable Sub PrintReport()
    End Sub
    Public Overridable Sub PrintReport()
        Dim activeDocument As ReportDocumentBase = Me.GetActiveDocument
        If (Not activeDocument Is Nothing) Then
        End If
    End Sub
    <DummyPermission(SecurityAction.Demand)> _
    Public Sub Print()
        Dim settings As PrinterSettings
        Dim dialog As New PrintDialog { _
            .AllowSomePages = True _
        settings = New PrinterSettings { _
            .MinimumPage = 1, _
            .FromPage = 1, _
            .MaximumPage = Me.GetLastPageNumber, _
            .ToPage = settings.MaximumPage _
        If (settings.MinimumPage <= settings.MaximumPage) Then
            Dim exception As Exception
            Dim document As New PrintDocument { _
                .PrinterSettings = settings, _
                .DefaultPageSettings = { Landscape:=Me.isPaperLandscape } _
            Dim kind As PaperKind = Me.getPaperKind
            Dim size As PaperSize
            For Each size In settings.PaperSizes
                If (size.Kind = kind) Then
                    document.DefaultPageSettings.PaperSize = size
                    Exit For
                End If
            dialog.Document = document
            Dim oK As DialogResult = DialogResult.OK
            New PrintingPermission(PrintingPermissionLevel.AllPrinting).Assert
                oK = dialog.ShowDialog
            Catch exception1 As Exception
                exception = exception1
                ExceptionEventService.HandleExceptionEvent(Me, exception)
            Catch obj1 As Object
                exception = New Exception("Non-CLS Exception")
                ExceptionEventService.HandleExceptionEvent(Me, exception)
            End Try
            If (oK <> DialogResult.OK) Then
                settings = Nothing
                AddHandler dialog.Document.PrintPage, New PrintPageEventHandler(AddressOf Me.PrintPageEventHander)
                Me.CurHorizontalPage = 1
                If (settings.PrintRange = PrintRange.AllPages) Then
                    Me.FromPage = 1
                    Me.CurPage = 1
                    Me.ToPage = settings.MaximumPage
                    Me.TotalHorizontalPage = 1
                    Me.FromPage = settings.FromPage
                    Me.CurPage = Me.FromPage
                    Me.ToPage = settings.ToPage
                End If
                Me.PrintCopies = settings.Copies
                Catch exception2 As Exception
                    exception = exception2
                    ExceptionEventService.HandleExceptionEvent(Me, exception)
                Catch obj2 As Object
                    exception = New Exception("Non-CLS Exception")
                    ExceptionEventService.HandleExceptionEvent(Me, exception)
                End Try
            End If
        End If
    End Sub

    Open in new window


    Author Comment


    Actually I did beleived you! The second question was psoted before your answer! I tried your suggestion and it work.

    Thanks sorry if  I did not sound like  I beleived you

    LVL 96

    Expert Comment

    by:Bob Learned
    Aah, yes, the old two questions asked because the first one wasn't answered trick (d'oh).  That is why it it really confusing when this happens.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    729 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

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now