0
votes

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
3
you might want to reinstall the add-on for crystal reportmaSTAShuFu
You are missing some critical files that are used for exporting Crystal Reports only. I do not recall what they are at the moment, I am not able to access my code. I do exactly what you're looking for - I export invoices to PDF files and go even further and e-mail them, all without user interaction other than initiating the function. If you don't have the correct export files, it will fail exactly as you stated. I have 8.5 but I'm sure they're the same for 8.0. I will look into this later this evening (if I can remember) and post a more specific answer then.Bill Hileman

3 Answers

1
votes

Here is the list of support files I use in my accounting software package regarding Crystal Reports exporting. It is a segment of an Inno-Setup script, but you should be able to get the idea from this list of what to look for:

; begin Export Destinations
Source: C:\WINDOWS\Crystal\u2d*.dll; DestDir: {pf32}\Seagate Software\SI\X86; Flags: sharedfile
Source: C:\WINDOWS\Crystal\u2d*.dll; DestDir: {win}\Crystal; Flags: sharedfile
; end Export Destinations

; begin Export Formats
Source: C:\WINDOWS\Crystal\u2f*.dll; DestDir: {pf32}\Seagate Software\SI\X86; Flags: sharedfile
Source: C:\WINDOWS\Crystal\u2f*.dll; DestDir: {win}\Crystal; Flags: sharedfile
Source: C:\WINDOWS\Crystal\crxf_*.dll; DestDir: {pf32}\Seagate Software\SI\X86; Flags: sharedfile
Source: C:\WINDOWS\Crystal\crxf_*.dll; DestDir: {win}\Crystal; Flags: sharedfile
; end Export Formats

; begin Page Ranged Export
Source: C:\Program Files (x86)\Seagate Software\Shared\ExportModeller.dll; DestDir: {pf32}\Seagate Software\Shared; Flags: sharedfile regserver
Source: C:\Program Files (x86)\Seagate Software\Shared\crtslv.dll; DestDir: {pf32}\Seagate Software\Shared; Flags: sharedfile regserver
Source: C:\Program Files (x86)\Common Files\Crystal Decisions\2.0\bin\ExportModeller.dll; DestDir: {pf32}\Common Files\Crystal Decisions\2.0\Bin; Flags: sharedfile regserver
Source: C:\Program Files (x86)\Common Files\Crystal Decisions\2.0\bin\crtslv.dll; DestDir: {pf32}\Common Files\Crystal Decisions\2.0\Bin; Flags: sharedfile regserver
; end Page Ranged Export
0
votes

I think I remember how it was done. Create a form and add the Report View. You can call this form but you dont need to show it. Assign the report to this instance and try to export to PDF.

0
votes

What you can do is export your CR to PDF and then print using ShellExecute.

This is the VB6 code to export to PDF:

Dim crxApplication As New CRAXDRT.Application
Dim Report as Object
Set Report = crxApplication.OpenReport("c:\temp\reportname.rpt")
With Report.ExportOptions
    .DestinationType = crEDTDiskFile
    .FormatType = crEFTPortableDocFormat
    .PDFExportAllPages = True
    .DiskFileName = "c:\temp\pdfname.pdf"
End With

Then you can use this to print the PDF:

 pid = ShellExecute(0&, "print", "c:\temp\pdfname.pdf", vbNullString, vbNullString, vbNormalFocus)