SET DEFAULT TO (this.cAppStartPath)
* Create a temporary data file.
lcTempFile = SYS(3) + ".dbf"
SELECT calldata
COPY TO (lcTempFile)
CLOSE DATA ALL
loReport = CreateObject("Crystal.CrystalReport")
* Set the report object properties.
loReport.ReportFileName = this.cAppStartPath + "calldata.rpt"
loReport.Destination = 2 && disk file
loReport.PrintFileName = lcOutputFile && name of output file
loReport.PrintFileType = 15 && RTF file
* Assign the temporary database to the crystal reports object.
loReport.RetrieveDataFiles()
loReport.DataFiles(0) = this.cAppStartPath + lcTempFile
* Generate the output file.
lnResult = loReport.PrintReport()
RELEASE loReport
CLOSE DATA ALL
IF !EMPTY(lcTempFile)
IF FILE(lcTempFile)
DELETE FILE (lcTempFile)
ENDIF
ENDIF
RETURN lnResult = 0
>loCRApp = CREATEOBJECT("Crystal.CRPE.Application")
>* Call crystal reports to create the Agency report
>loCrReport = loCRApp.OpenReport("D:\Work\AgLeads3.Rpt")
>loCrDatabase = loCrReport.Database()
>loCrExportOptions = loCrReport.ExportOptions()
>
>* Set the Crystal Report options
>loCrExportOptions.DestinationType = 1
>loCrExportOptions.FormatType = 4
>loCrExportOptions.DiskFileName = laAttach[lnAttach]
>loCrReport.DiscardSavedData()
>loCrReport.ParameterPromptingEnabled = .F.
>
>* Create the RTF file
>loCrReport.Export(.F.)
>
>* Reset the CR Options
>loCrExportOptions.Reset()
>
>* Clear the report objects
>loCrReport = .NULL.
>loCrDataBase = .NULL.
>loExportOptions = .NULL.
>