Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I run a Crystal Reports report from VFP?

COM and Automation

How can I run a Crystal Reports report from VFP?

by  foxdev  Posted    (Edited  )
(the information in this FAQ applies to version 8 of Seagate Crystal Reports, but may apply to other versions as well)

With just a few lines of code you can run, print, or export a Crystal Reports report that you have already designed. If you have already designed and tested the report within CR, you can use the following techiques to invoke the report:

Export a report in Word format
[tt]oCRApp = createobject("crystal.crpe.application")
oRep = oCRApp.OpenReport("C:\MYREPORT.RPT")
oRep.ExportOptions.FormatType = 14 && Word
oRep.ExportOptions.DiskFileName = "c:\test.doc"
oRep.ExportOptions.DestinationType = 1 && disk file
oRep.Export(.F.) && .F. = no dialog box
release oRep
release oCRApp[/tt]

In the above example, use FormatType 4 for RTF, 27 or 28 for Excel 7, 29 or 30 for Excel 8.

Preview a report
[tt]oCRApp = createobject("crystal.crpe.application")
oRep = oCRApp.OpenReport("C:\MYREPORT.RPT")
oRep.Preview [/tt]

Print a report to the default printer
[tt]oCRApp = createobject("crystal.crpe.application")
oRep = oCRApp.OpenReport("C:\MYREPORT.RPT")
oRep.Printout(.F.) && .F. = no printer dialog[/tt]


Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top