VB6 + Crystal Reports 7 Viewer - Export creates blank file

Posted on 2011-05-09
Last Modified: 2012-05-11
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

Question by:Iamtehbest
    LVL 100

    Accepted Solution

    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?


    Author Comment


    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.

    LVL 100

    Assisted Solution

    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.


    Author Comment


    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?

    LVL 100

    Expert Comment

    I don't know for sure.

    I think it was crEFTXLS


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
    You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now