Thursday, May 17, 2012
Call Toll Free: (877) 723-1442 U.S. and Canada
Quick Menu
ActiveX / COM
Visual C++ / MFC
Case Studies
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, 2008
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