Hi, I am nearly there with my reporting app! The final piece is to export reports, I have copied code found on the forum to complete this task but I am getting an error:
System.Runtime.InteropServices.COMException was caught
ErrorCode=-2147467259
HResult=-2147467259
Message=Unspecified error
Source=rptcontrollers.dll
StackTrace:
at CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.Export(ExportOptions pExportOptions, RequestContext pRequestContext)
at CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext)
at CrystalDecisions.CrystalReports.Engine.FormatEngine.ExportToStream(ExportRequestContext reqContext)
at CrystalDecisions.CrystalReports.Engine.FormatEngine.Export(ExportRequestContext reqContext)
at CrystalDecisions.CrystalReports.Engine.FormatEngine.Export()
at CrystalDecisions.CrystalReports.Engine.ReportDocument.Export()
at TransLite_Browser.reportHost.TestReport() in C:\temp\TransLite_Browser\TransLite_Browser\reportHost.xaml.vb:line 89
InnerException:
The code I am using is below and is running in the same function that loads the report:
CyrstalRptsViewer.ViewerCore.ReportSource = cryRpt
Try
Dim CrExportOptions As ExportOptions '= cryRpt.ExportOptions
Dim CrDiskFileDestinationOptions As New _
DiskFileDestinationOptions()
Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions
CrDiskFileDestinationOptions.DiskFileName = "C:\jobreport.pdf" 'pdfFile
CrExportOptions = cryRpt.ExportOptions
With CrExportOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
.DestinationOptions = CrDiskFileDestinationOptions
.FormatOptions = CrFormatTypeOptions
End With
cryRpt.Export()
Catch ex As Exception
MsgBox("Error exporting report: " & ex.ToString)
End Try
Why the error is something out of place?