CRYSTAL REPORT XI print to printer

Post Reply
User avatar
dutch
Posts: 1395
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

CRYSTAL REPORT XI print to printer

Post by dutch »

Dear All,

I try this code for Preview and Export to file, it's work well but print to printer doesn't work and got an error.

oRpt:SelectPrinter( cPrinter ) // Error missing method
oRpt:PrintOut("False",nCopy) // Error missing method


Thanks in advance for any help or suggestion.

Code: Select all

*----------------------------------------------------------------------------------*
Procedure CRReport(nOpt, cReport, filter_main, nExport, cTempFile, cPrinter, nCopy)
local oWnd, oCRViewer, oCrystal, oRpt, oExp, oCRParameterField, oRptOut

   cReport := MEMVAR->cCRPath+cReport  // "C:\Users\dutch\Desktop\CR11\VatReport.rpt"   // Report Name
   oCrystal:= CreateObject("CrystalRuntime.Application.11")     // Declare CreateObject
   oRpt    := oCrystal:OpenReport(cReport)          // Open Report
   oRpt:DiscardSavedData()          
    oRpt:RecordSelectionFormula( filter_main )  // Query database
    oRpt:EnableParameterPrompting("False")    
    // oRpt:DisplayProgressDialog := 1
    
   DEFINE WINDOW oWnd FROM 3, 6 TO 20, 70 ;
      TITLE "Print and Preview"
        
        if nOpt = 1   // Print to Printer
            oRpt:SelectPrinter( cPrinter )  // Error missing method
            oRpt:PrintOut("False",nCopy) // Error missing method
        elseif nOpt = 2  // Preview

            oCRViewer := TActiveX():New( oWnd, "CrystalReports.ActivexReportViewer" )  
            oWnd:oClient := oCRViewer
                
            oCRViewer:EnableExportButton := 0
            oCRViewer:EnableStopButton:= 1
            oCRViewer:EnableNavigationControls:=1
            oCRViewer:EnablePopupMenu:=0
            oCRViewer:EnableCloseButton:=0
            
            oCRViewer:DisplayGroupTree:=1
            oCRViewer:EnableDrillDown:=1
            oCRViewer:EnableGroupTree:=1
            oCRViewer:EnableStopButton:= 0
            oCRViewer:EnablePrintButton  := iif( nOpt=2,0,1)
            oCRViewer:ReportSource:= oRpt
            oCrViewer:Zoom:=100
        
            if nOpt = 1     
                oCRViewer:PrintReport()
            else
                oCRViewer:ViewReport()
            end
            
        elseif nOpt = 3  // Export

           oExp := oRpt:ExportOptions
           oExp:DestinationType := 1
           oExp:ExcelShowGridLines := 0 // 1
           oExp:FormatType := nExport   // 36 = Full Excel
           oExp:DiskFileName := cTempFile // "D:\TESTCR27.XLS" 
        
           oRpt:Export(.F.)  // Parameter .T./.F. = oExp:PromptForExportOptions()
           oWnd:End()

        end 
        
   ACTIVATE WINDOW oWnd MAXIMIZED;
      VALID (oRpt:CancelPrinting(),oCrystal:CanClose(),oRpt := nil ,.t.)
            
return
 
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
AHF
Posts: 837
Joined: Fri Feb 10, 2006 12:14 pm

Re: CRYSTAL REPORT XI print to printer

Post by AHF »

Dutch,

Just an idea:

Code: Select all

PrinterSetup(),;
oReport:SelectPrinter(PrnGetDrive(),PrnGetName(),PrnGetPort()),;
oReport:PrintOut(.F.)
 
I think "False" must be .F.
Regards
Antonio H Ferreira
User avatar
dutch
Posts: 1395
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: CRYSTAL REPORT XI print to printer

Post by dutch »

I've got it.
Thank Antonio,
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
Post Reply