Toll Free: (877) 723-1442 U.S. and Canada
Support
ActiveX / COM
Visual C++ / MFC
Customer Spotlight
Corporate Partners
Contact Sales

Call center available M-F 9:00 - 6:00 US Eastern Time.

U.S. and Canada
(877) 723-1442

International
(517) 625-5729

Email

Printing a Report

Author: Mike Palmatier
Posted: May 3, 2006
Environment: Visual Basic 6.0

To print a report only a single line of code is needed. The PrintReport method is used to print the currently visible report. A zero 0 is passed in as the only parameter to use the systems default printer.

'Printing using the default printer dialog

wndReportControl.PrintReport 0

You can also use the CommonDialog control to print. With a CommonDialog control, the CommonDialog.hDC property returns a device context for the printer selected in the Print dialog box when the cdlReturnDC flag is set. See the sample below for more on how to do this.

'Printing using the CommonDialog Control

    On Error Resume Next

 

    With dlgCommonDialog

        .DialogTitle = "Print"

        .CancelError = True

        .Flags = cdlPDReturnDC + cdlPDNoPageNums

        .ShowPrinter

        If Err <> MSComDlg.cdlCancel Then

            wndReportControl.PrintReport .hDC

        End If

    End With

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Other products and/or company names may be trademarks or registered trademarks of their respective owners.