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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exporting Crystal Report to Excel 1

Status
Not open for further replies.

bradth

IS-IT--Management
Feb 18, 2005
142
CA
I am currently running Crystal reports 8 on windows 2000 and have Microsoft Excel 2000. What I was wondering is, is it possible to export a crystal report into an excel document? I have VB code written that pulls a crystal report from a button on a form that I have created and ideally would like to have another button that would export that crystal report into an excel document. Any ideas?
 
I guess I should specify this a little clearer. What I would like to do is through VB code, export the crystal report to excel. Right now my VB code exports the crystal report to a CRViewer. I would like it to come up in the viewer as well as export to excel. I know you can just open up the report itself and export it to excel. I just don't know how to do this through VB code. Any code or help would be much appreciated. Thanks in advance.
 
Because it's Friday, and I'm giddy from not enough sleep:
Code:
'Declare the necessary objects
Dim crxApp As New CRAXDRT.Application
Dim crxRpt As CRAXDRT.Report
Dim strExportPath As String
Dim crxExportOptions As CRAXDRT.ExportOptions

'Open the report
Set crxRpt = crxApp.OpenReport("C:\ReportName.rpt")

'Set up your parameters/login info, etc.  then....

'Set up your export options
strExportPath = "C:\"
Set crxExportOptions = crRpt.ExportOptions
crxExportOptions.FormatType = crEFTExcel80
crxExportOptions.DestinationType = crEDTDiskFile
crxExportOptions.DiskFileName = strExportPath & "Exported.xls"

'Export the report without prompting the user
crxRpt.Export False

'Send the report to your CRViewer
CRViewer.ReportSource = crxRpt
CRViewer.ViewReport

-dave
 
Thanks for the code, it looks like it'll work, only one problem. When i put it in my code, i get Runtime error '424' "Object required on this line:

Set crxExportOptions = crRpt.ExportOptions

What would the problem be?
 
Typo... change crRpt to the name of your report object.

-dave
 
Ya, it should be crxRpt, sorry bout that, I seen my error right after I posted this. Thanks much though, that works perfect. Cheers.

Brad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top