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!

Any one helpppp......Export crystal report from VB

Status
Not open for further replies.

ravioli

Programmer
Mar 30, 2004
39
US
Hi I am using VB6, CR8. I have developed a crystal report and was able to successfully print it to a window using VB6.
But I am unable to export the Report to a file. This is what I have coded, i am not getting my out put exported to the word doc. Please help me with the syntax If I am missing any pieces of it.
CrystalReport1.PrintFileName = ("c:\dates.doc")
CrystalReport1.ReportFileName = ("c:\dates.rpt")
CrystalReport1.SelectionFormula = "{issues.date}= DATE(" & Format(dt, "YYYY") & "," & Format(dt, "MM") & "," & Format(dt, "DD") & ")"
CrystalReport1.PrintReport
CrystalReport1.Destination = crptToFile

Thanks in advace
 
I am getting the result printed to the window succesfully without changing the date format. The only thing changed,i.e, the selection formula works fine when I print it to a window.

CrystalReport1.Destination = crptTowindow --->
CrystalReport1.Destination = crptToFile



 
Code:
    Dim CrDB As Database
    Dim CrTables As DatabaseTables
    Dim CrTable As DatabaseTable
    Dim crRep As Report
    Dim crapp1 As New CRAXDRT.Application
    Dim crExportOptions As CRAXDRT.ExportOptions
    
    Set crapp1 = New Application
    Set crRep = crapp1.OpenReport("MyReport.rpt")
    Set crExportOptions = crRep.ExportOptions
    
    crRep.ParameterFields(1).AddCurrentValue sValue
    crExportOptions.DestinationType = crEDTDiskFile
    crExportOptions.FormatType = crEFTExcel7
    crExportOptions.DiskFileName = "e:\exports\Myfile.xls"
    'crRep.ExportOptions = crExportOptions
    crRep.Export False

Better? :)

--NipsMG

Note... crExportOptions has enumerated types which pop up in a listbox when you type the = character to assign a value to them, so you can pick and choose from the types and such.


 
I have tried using the code, but I am getting a compile error "User-defined type not defined ". I am getting the same message for every declaration.
Dim CrDB As Database
Dim CrTables As DatabaseTables
Dim CrTable As DatabaseTable
Dim crRep As Report
Dim crapp1 As New CRAXDRT.Application
Dim crExportOptions As CRAXDRT.ExportOptions



Thanks inadvance...
 
do you have the Report Design Component installed on your computer? If so, you should be able to go to Projects, -> Components -> Designers and select Crystal Reports 8.. go to Project Menu and select Add Crystal Reports 8.

This will add the Crystal Reports Designer Component to your project.

Then you should have references to everything you need. If not look for CRAXDRT.DLL on your computer and add it as a reference.. that might work..

--NipsMG
 
I have added cr8 designer to my project, now it accepts the declarations. But I am getting an error "Missing or out-ofdate export DLL". I have installed cr8 and vb6 very recently and I am not sure how come they are old or what DLLS are missing......Can you please help

Thanks inadvance...
 
I am getting the error right at the statement
crrep.export false
 
ok.. this is where it gets tricky.. Crystal Reports 8 is VERY BUGGY... :(

First Thing, get on and find the new version of craxdrt.dll for Version 8.

Then, put in the CR8 cd, and MAKE SURE that you have selected all of the export types from the install tree or else you will not be able to export.

Once you do these 2 things you should be able to export without a problem.

Note: This can be VERY USEFUL.....

Example: You have a report to tell customers their status, and there is a parameter in the report for CustomerName.

If you have these customer names stored in a database somewhere, you can select the names into a recordset, loop through the recordset, set the parameter, generate, export to file (FileName = "ReportName" & rstCustomer!CustomerName & ".xls"), and recordset.movenext. you can also automatically e-mail reports by swapping options, which is very cool if you have an up to date source with working e-mail addresses for contacts. :)

Have some fun with it, I hope you get it working.

--NipsMG
 
Hi NipsMG...Thanks very much for the HELP....
Now It works perfect ....Thanks BUNCH...s-) s-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top