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

How do I export Crystal reports from VB?

Status
Not open for further replies.

aplusc

Programmer
Feb 17, 2002
44
US
I need to write a function which would automatically export a report and open it in Excell. This is possible to do by clicking the "Export" button on the toolbar, but it is annoying to choose the same settings everytime. I know it's possible to automate this, but I have no idea how.
 
aplusc and Parnini,
I have been trying to do the same thing. When I try to do this I still get the dialog asking me what I want to do. I know there is a parameter to prompt the user and I set that to false but then nothing happens. Do you have any suggestions? Thanks in advance...
 
Add the following code under the ExportButtonClicked event:

UseDefault = False
Report.ExportOptions.DiskFileName = "c:\pdf_report.pdf"
Report.ExportOptions.DestinationType = crEDTDiskFile
Report.ExportOptions.FormatType = crEFTExcel50
Report.Export False
 
Parnini,
Thanks for your help...It worked great! I have tried doing the same thing but exporting to html and I get a fail everytime...I have used a few different options in the export options in every possible order I could think of but I keep getting fails. Do you know of a bug or am I just doing something wrong again?

Here is the code I have:
Code:
Address = App.Path & "\" & "tearsheet" & EContactID & ".html"
UseDefault = False
Report.ExportOptions.DiskFileName = Address
Report.ExportOptions.DestinationType = crEDTDiskFile
Report.ExportOptions.FormatType = crEFTHTML40
Report.ExportOptions.HTMLEnableSeparatedPages = True
Report.ExportOptions.HTMLHasPageNavigator = True
Report.ExportOptions.HTMLFileName = "tearsheet" & EContactID & ".html"
Report.Export False
Any suggestions would be greatly appreciated once again...
 
Don't set the DiskFileName property for HTML export. DiskFileName is the location for exporting to Excel and PDFs and some other formats.

Make sure you have the latest export drivers. Early 8.5 drivers caused Dr.Watson when exporting to HTML from code in some situations.
 
mwardle,
Thanks for the advice...I went and downloaded the drivers an took out the diskfilename and now I get a permission denied error. I have put in different filename's with the path and without...Do you have any other suggestions? Sorry to be a pain, I'm new at crystal :)

Thanks again...
 
Does it work with other export formats?
Are you able to export to the location desired from within Crystal itself?
Does it fail with any report, or just the one being tested? There are some limitations to all the export formats.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top