Allo
I Have some code that I'm using to print a report in Crystal. I was working with the ver. 6.0 and use the activeX OCX but it's very limited. If you want a read OOP and a lot of control, go to 8.0 or even 8.5. With 8, you have a better control over your object. The data objects are better (a collection of tables, fields, ...).
Here some code for OCX and RDC. Hope it will Help..
LPARAMETER tcCRType, tnOutput
lcPrtDrv = "winspool"
lcPrtName = "HP DeskJet 810C Series Printer"
lcPrtPort = "USB/DeskJet 810C/SG93V1V10BGI"
lcReport = "c:\apps\inv\crystal\inv_fact01.RPT"
DO CASE
CASE tcCRType = "OCX" && Crystal Ver 6 or 7
loCrystalReport = NEWOBJECT("crystal.CrystalReport"
*** Open the report ***
loCrystalReport.ReportFileName = lcReport
*** Set the printer information ***
loCrystalReport.PrinterName = lcPrtName
loCrystalReport.PrinterDriver = lcPrtDrv
loCrystalReport.PrinterPort = lcPrtPort
*** Printing ***
IF tnOutput = "PRINTER"
loCrystalReport.ReportSource = 1 && 1 -> Printer
ELSE
loCrystalReport.ReportSource = 0 && 0 -> Preview
ENDIF
loQ9000Print.oCrystalReport.PrintReport
CASE tcCRType = "RDC" && Crystal Ver 8 and 8.5
loCrystalReport = NEWOBJECT("Crystal.CRPE.Application"
*** Open the report ***
loCrystalRp = loCrystalReport.OpenReport(lcReport)
*** Set the printer information ***
loCrystalRp.SelectPrinter(lcPrtDrv, lcPrtName, lcPrtPort)
IF tnOutput = "PRINTER" && -> Printer
loCrystalRp.Printout(.F.,1,.F.)
ELSE
loCrystalRp.Preview && -> Preview
ENDIF
ENDCASE