PDA

Click to See Complete Forum and Search --> : Crystal to EXCEL


Pasvorto
Jan 22nd, 2003, 10:45 AM
I have Crystal Report Writer 85.. I want my vb6 app to run the report that will export the data to EXCEL.

My questions are:

Do I need this code?
Report.SelectPrinter glbPrinterDriver, glbPrinterName, glbPrinterPort

I know I need:
Set Report = crxApplication.OpenReport("C:\AvedaXL.rpt", 1)
Report.PrintfileType = 19 'EXCEL5
Report.PrintFileName = "C:\Aveda.xls"
Report.PrintOut False

When the report is done, I need to have an EXCEL sheet created.

ducky
Jan 23rd, 2003, 03:24 PM
Almost. You don't need the Report.SelectPrinter since you're only exporting, and don't use any of the print objects. Also if your exporting to excel I believe you have the wrong export code.

You minimal code would be:


Set Report = crxApplication.OpenReport("C:\AvedaXL.rpt", 1)
Report.ExportOptions.FormatType = crEFTExcel80
Report.ExportOptions.DiskFileName = "C:\Aveda.xls"
Report.ExportOptions.DestinationType = crEDTDiskFile
Report.Export False


If your DB used in the report requires login, you'll also have to set the login info for each table like the following:


For Each crpTable In Report.Database.Tables
crpTable.SetLogOnInfo "myhost", , "myusername", "mypassword"
Next