VB6 + Crystal Reports 7 Viewer - Export creates blank file

I have a VB6 application that uses the CRViewer control to display a report, the report displays perfectly, but when I click the Export button the file created is blank.  This occurs with all of the options (Excel 7.0, TXT, RTF, Word, etc).  I would prefer to export it to an Excel 7.0 but Word would also be acceptable.

Steps I have tried:
Can export from another application that is not using CRViewer control but the CrystalReport control.
Reinstalled CR 7 to be safe
Copied all DLLs from c:\winnt\crystal to c:\winnt\system32 and registered.

Any help would be appreciated.  This is a Windows 2000 development pc.

Code for the CRViewer open & populate:

Public ReportEngine As New CRAXDRT.Application

Private Sub Form_Load()
    Dim Xrec As New ADODB.Recordset
    Dim Yrec As New ADODB.Recordset
    Dim Zrec As New ADODB.Recordset
    Dim SubReport As CRAXDRT.Report
    Dim SubReport2 As CRAXDRT.Report
    Dim temp As Integer
    Set Report = ReportEngine.OpenReport(Crystal_ReportPath)
    Report.ReportTitle = Crystal_ReportName
    Xrec.Open Crystal_SQL, MyDB, adOpenForwardOnly, adLockOptimistic, adCmdText
    temp = Report.Database.Tables.Count
    For i% = 1 To Report.Database.Tables.Count
        Report.Database.Tables(i%).SetLogOnInfo "", "", "", ""
    Next i%
    Report.Database.SetDataSource Xrec, 3
    If Crystal_SubReportPath <> "" Then
        Set SubReport = Report.OpenSubreport(Crystal_SubReportPath)
        SubReport.Database.SetDataSource Yrec, 3
        Yrec.Open Crystal_SubSQL, MyDB2, adOpenForwardOnly, adLockOptimistic, adCmdText
        For i% = 1 To SubReport.Database.Tables.Count
            SubReport.Database.Tables(i%).SetLogOnInfo "", "", "", ""
        Next i%
    End If
    If Crystal_SubReportPath2 <> "" Then
        Set SubReport2 = Report.OpenSubreport(Crystal_SubReportPath2)
        SubReport2.Database.SetDataSource Zrec, 3
        Zrec.Open Crystal_SubSQL2, MyDB, adOpenForwardOnly, adLockOptimistic, adCmdText
        For i% = 1 To SubReport2.Database.Tables.Count
            SubReport2.Database.Tables(i%).SetLogOnInfo "", "", "", ""
        Next i%
    End If
    Me.Caption = Report.ReportTitle
    Screen.MousePointer = vbHourglass
    CRViewer1.ReportSource = Report
    Screen.MousePointer = vbDefault
    Me.Visible = True
    Loop Until CRViewer1.IsBusy = False
    CRViewer1.Zoom 125
    Set Xrec = Nothing
    Set Yrec = Nothing
    Set Zrec = Nothing
End Sub

Open in new window

Who is Participating?
DO you need to export from the viewer or can you export from code

'   Set export options
    Report .ExportOptions.DestinationType = crEDTDiskFile
    Report .ExportOptions.DiskFileName = txtAttachmentFile
    Report .ExportOptions.FormatType = crEFTWordForWindows
    Report .Export False
    Set crRpt = Nothing

When you export from the viewer do you get to enter the path?
If you select application does the application open and have data?

IamtehbestAuthor Commented:

Yes, I need to export from the viewer.
Yes when I export from the viewer I get to enter the path, the file is created, it is just empty (0 bytes)
No, if I select application the application does not open.

There was an issue at one point which resulted in 0 byte files.

Apparently it is a known issue and was never resolved for CR7.

If you export through code does it worK?
If so you could add an export button of your own and do the export.

IamtehbestAuthor Commented:

I tested out the code you provided for exporting from code, and it did work, do you by any chance know the .formatType for exporting to Excel?

I don't know for sure.

I think it was crEFTXLS

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.