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

Export to Excel

Status
Not open for further replies.

williey

Technical User
Jan 21, 2004
242
I have automate a set of Crystal reports using VB script. Now I need to export some reports to Excel. But I run into the error of "crEFTExcel80" is being a valid property or method. BTW, I'm running CR 8.5.

Here is a snippet of my code..

Code:
' Declare variables
Dim oRptApp, oRpt, oRptParam1
Dim oRptExportOptions


' Set the object for the App
Set oRptApp = CreateObject("CrystalRuntime.Application")


 
  ' ### Set the object for the 1C2A Risk Weighting Report
  Set oRpt = oRptApp.OpenReport(INPUT_PATH & IN_FILE31, 1)

  ' Set the first parameter
  Set oRptParam1 = oRpt.ParameterFields.Item(1)
 

  ' Clear the first parameter value
  oRptParam1.ClearCurrentValueAndRange

  ' Set the value of the first param
  oRptParam1.AddCurrentValue CDate(endDate)

  ' Set export options
  Set oRptExportOptions = oRpt.ExportOptions
  oRptExportOptions.FormatType = oRpt.crEFTExcel80
  oRptExportOptions.DestinationType = crEDTDiskFile
  oRptExportOptions.DiskFileName = "C:\test.xls"

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




------------------------------------------
There are 10 kinds of people in this world. One that understands binary and the other one that does not.
 
Unless you have some deep rooted psychological need to write programs, there are already applications out there to schedule and export crystal reports. Visual CUT by Millet Software is my favorite, and very reasonably priced at <$400.


Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports
 
Don, thanks for the kind words... :eek:)

Assuming you can't resist the "need", I think it's a simple matter of changing:
oRptExportOptions.FormatType = oRpt.crEFTExcel80
to
oRptExportOptions.FormatType = crEFTExcel80

Cheers,
- Ido

Visual CUT & DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
Hmm.. I removed the "oRpt." and reran it.. Now I have the error msg of "Variable is undefined: 'crEFTExcel80'"



------------------------------------------
There are 10 kinds of people in this world. One that understands binary and the other one that does not.
 
Ok.. I figure out what the problem is. Since I'm using VB script instead of VB. I have to use the actual value instead of the CONSTANT name. The following changes fixed the problem.


Code:
oRptExportOptions.FormatType = 29   oRptExportOptions.DestinationType = 1

------------------------------------------
There are 10 kinds of people in this world. One that understands binary and the other one that does not.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top