htmlvb6crystal-reportsexport

Why do I get a "Failed to export the report" error when I try to export a Crystal Report to an HTML file?


I'm trying to export a Crystal Report to an HTML file, but when I call the Export method, I immediately get this error:

Source: Crystal Reports ActiveX Designer

Description: Failed to export the report.

I have tried both crEFTHTML40 and crEFTHTML32Standard as export format types - and both result in the same error.

Here is a highly simplified version of what I'm doing:

Dim objCRReport As CRAXDRT.Report
[...]
objCRReport.ExportOptions.FormatType = 32 'crEFTHTML40
objCRReport.ExportOptions.DestinationType = 1 'crEDTDiskFile
objCRReport.ExportOptions.DiskFileName = "C:\reportInHtmlFormat.html"
objCRReport.Export False '<--- "Failed to export the report" error here

Please note that I am referencing the "Crystal Reports 9 ActiveX Designer Runtime Library" specifically.


Solution

  • I'm not sure what you have in the [...] section but your code should include a call to open the report with an instance of the CRAXDRT Application.

    Dim objCRReport As CRAXDRT.Report
    
    '***********************************
    Dim objCRApp As New CRAXDRT.Application
    
    objCRReport = objCRApp.OpenReport("<YOUR REPORT FILENAME>", 1)
    '***********************************
    
    [...]
    objCRReport.ExportOptions.FormatType = 32 'crEFTHTML40
    objCRReport.ExportOptions.DestinationType = 1 'crEDTDiskFile
    objCRReport.ExportOptions.DiskFileName = "C:\reportInHtmlFormat.html"
    objCRReport.Export False '<--- "Failed to export the report" error here