I'm trying to build a VB6 console application to automatically export Crystal Reports to PDF format. This needs to be done without user interaction (no Save As or Print dialog boxes). The idea is to replace an existing application that uses Neevia DocCreator to print to PDF, but requires the user to interact with a Save As dialog for each report.
Due to our company's situation, I am constrained to VB6 and Crystal Reports 8.0. I can't purchase any additional software or download 3rd party open source software, that is forbidden by policy.
I'm running into a problem when doing the actual export. In the code below, using a sample report for testing, the line "oXRpt.Export False" throws an error, "Missing or out-of-date export DLL." I have not been able to determine which dll it's referring to. The Crystal Report Export reference in the project points to C:\Program Files\Seagate Software\Viewers\ActiveXViewer\sviewhlp.dll. That dll exists in the referenced directory.
Has anyone successfully done this, or does anyone have knowledge of which dll may be the problem? I can also accept a solution that prints to PDF without any user interaction (we do not have full Adobe Acrobat and this company will not be buying it; not my decision, sorry). Here's my code:
Sub Main()
Dim oXApp As CRAXDRT.Application
Dim oXRpt As CRAXDRT.Report
Dim oXOpt As CRAXDRT.ExportOptions
On Error GoTo ExportErr
Set oXApp = CreateObject("CrystalRuntime.Application")
Set oXRpt = oXApp.OpenReport(App.Path & "\C1910X.rpt") '"\C0562.rpt")
oXRpt.RecordSelectionFormula = "{REPORT_HEADER.ReportControlID} = " & 1985735
With oXRpt
.EnableParameterPrompting = False
.MorePrintEngineErrorMessages = True
End With
Set oXOpt = oXRpt.ExportOptions
With oXOpt
.DestinationType = crEDTDiskFile
.DiskFileName = App.Path & "\C1910X.pdf"
.FormatType = crEFTPortableDocFormat
End With
oXRpt.Export False 'throws missing or out-of-date dll error
ExportErr:
MsgBox Err.Number & ", " & Err.Description
End Sub