Skip to Content
0
Jun 09, 2011 at 11:42 PM

Accessing SavedExportOptions

92 Views

vb.net, VS 2008, Cr 2008 SP3 FP 3.5

I'm trying to instantiate saved export options using the following code:

Dim rcd As CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument

rcd = MyReport.ReportClientDocument

Dim myExcelFormatOptions As New CrystalDecisions.Shared.ExcelDataOnlyFormatOptions

myExcelFormatOptions = CType( rcd.SavedExportOptions ( CrystalDecisions.ReportAppServer.ReportDefModel.CrReportExportFormatEnum.crReportExportFormatRecordToMSExcel), CrystalDecisions.Shared.ExcelDataOnlyFormatOptions)

However, the last step of instantiating the myExcelFormatOptions fails with the following message:

"Unable to cast COM object of type 'System.__ComObject' to class type 'CrystalDecisions.Shared.ExcelDataOnlyFormatOptions'. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface."

Question: can you provide sample code on how I can instantiate an object holding saved export options for a given format?

Thanks,

- Ido