Crystal Report using Adobe Reader to view under VB6 development

Posted on 2007-10-08
Last Modified: 2013-12-26
Hi all,

I am using Visual Basic 6. And my report is using Crystal Report 8.5 to develope. I am doing the Windows application using VB6.
On my windows application, when I click on the preview button, I will use the below coding to export my crystal report to PDF file, and use Adobe Reader to open the PDF file.
                    Private Sub PrintReport()
                         Dim crReport As New cr_po

                         crReport.ExportOptions.ApplicationFileName = "C:\Purchase_Order.pdf"
                         crReport.ExportOptions.DestinationType = crEDTApplication
                         crReport.ExportOptions.DiskFileName = "C:\Purchase_Order.pdf"
                         crReport.ExportOptions.PDFExportAllPages = True
                         crReport.ExportOptions.FormatType = crEFTPortableDocFormat
                         crReport.Export False
                    End Sub

When the report being view in the adobe reader. Then I go to my windows application and click the "Preview" button again, it will having an error by saying that
                                          " Run-time error '-2147206452 (80043acc)' "
                                          The file is use by another application.

I know this is because of the PDF file is being open, my another PDF file is creating and using the same file name. I just want to know is there any other way to view the Crystal Report file in PDF?

Thanks & Best regards.
Question by:runbird
    LVL 100

    Expert Comment

    What happens if you comment out or delete this line
    crReport.ExportOptions.DiskFileName = "C:\Purchase_Order.pdf"


    Author Comment

    Even though I comment out this line >> crReport.ExportOptions.DiskFileName = "C:\Purchase_Order.pdf"
    I am still getting the same error. Because when one pdf file is browsing, another pdf file will not be able to export with the same file name.

    LVL 100

    Accepted Solution

    What if you modified the filename to include a global variable

    Something like this
    FileNameModifier = FileNameModifier + 1
    crReport.ExportOptions.DiskFileName = "C:\Purchase_Order_" & CStr(FileNameModifier,0) & ".pdf"


    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    731 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

    19 Experts available now in Live!

    Get 1:1 Help Now