views:

2224

answers:

2

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.

+1  A: 

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("", 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

Thanks. Unfortunately, I'm no longer working on this code (we're no longer using Crystal for this). I will eventually go back to the old code to try what you described, but for the time being you get a +1 for your answer.At that time, if I determine it to be the solution, I'll mark it as the answer.
Matt Refghi
A: 

objCRReport.ExportOptions.HTMLFileName = "C:\reportInHtmlFormat.html"

ANeto