Solved

Exporting Crystal Report to PDF upon Form loading in VB

Posted on 2003-12-03
8
2,465 Views
Last Modified: 2008-02-26
I am trying to get a Crystal report to automatically export to a PDF file at a specific name and location. I want this to occur on the form load event (or form activate event) in a VB6 project. I beleive I have almost all the parts needed to do this but I still am having some dificulty.

I want the Report called "crptLocalTest.dsr" which is already in the project as a crystal report.
           (or I can also run a "LocalTest.rpt" that can be in the local app directory)
I want it to export in PDF format to the directory called C:\Temp\
I want it named Output.pdf
It will also need to overwrite the "Output.pdf that will be currently in the directory.

I want this all to occur withiut any prompting past starting the VB app. It seems like I need to modify some of the code below that I have been working with.....


    crptLocalTest.Export
    crptLocalTest.ExportOptions.DiskFileName = ("C:\Temp\Output.PDF")
    crptLocalTest.Action = 1
    crptLocalTest.ExportOptions.FormatType = crEFTPortableDocFormat


Can anybody help me make my way through this, I am pretty new to VB so try to keep it as simple as possible.
Thanks
0
Comment
Question by:DavidNPD
  • 4
  • 3
8 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 9868931
0
 

Expert Comment

by:deguy
ID: 9868956
There isn't much to it.  Assuming that your report doesn't require any user interaction such as logging on to the database, or supplying parameter values, simply set up the values you want in the .ExportOptions object first, then call the .Export() method.

You may wish to include ".ExportOptions.PDFExportAllPages = true" in order to ensure that all pages are included, but that's about it in addition to what you quoted above.  The only other thing I would mention is that should you wish to suppress Crystal's export options prompts, don't forget to supply the "false" argument to Report.Export().

Hopefully this will get you going...  if not, post a comment any specific problems your are encountering, and someone will get you on your way.

-d.
0
 

Author Comment

by:DavidNPD
ID: 9869237
mlmcc,
I have been working with that sample app. That his how I got as far as I did. I am using 8.5 deveolopers edition.


deguy, one specific problem that I am having is that when I use

crptLocalTest.Export (false) to surpress the confirmations I get an error: "Runtime error '-2147190548" telling me that the export DLL are not installed. They are and they work when I get the prompts but when I try to use "False" I get the error.

Can you see any mistakes in the code sample I have supplied, because that just brings up the dialog box for confirmations.
0
 

Expert Comment

by:deguy
ID: 9869360
>Can you see any mistakes in the code sample I have supplied, because that just brings up the
>dialog box for confirmations.

From the code you posted it looks as though you're calling the .Export() method before you set up the .ExportOptions object.  Is that correct?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:DavidNPD
ID: 9874771
The exact code, that is located in the Form_load area is this:

        crptLocalTest.ExportOptions.PDFExportAllPages = True
        crptLocalTest.ExportOptions.FormatType = crEFTPortableDocFormat
        crptLocalTest.ExportOptions.DiskFileName = (App.Path & "\Output.PDF")
        crptLocalTest.Export (False)

When I do it this way  (with the promt to false) I get an error that says:

Run-Time error '-2147190548 (800478ec)':
Missing or out-of-date export DLL.

But in fact I do have the export dls installed, as if I do not ask for the prompt to be supressed I can actually export the report correctly, though it asks me for the pages, location and file name.

0
 

Accepted Solution

by:
deguy earned 100 total points
ID: 9874855
Oops...  I missed a vital part yesterday.  Are you setting the .DestinationType property of .ExportOptions?  It should be crEDTDiskFile for exports to disk.

-d.
0
 

Author Comment

by:DavidNPD
ID: 9874886
THAT did it !
Here is the code that is now working, Thanks

        crptLocalTest.ExportOptions.PDFExportAllPages = True
        crptLocalTest.ExportOptions.FormatType = crEFTPortableDocFormat
        crptLocalTest.ExportOptions.DiskFileName = (App.Path & "\Output.PDF")
        crptLocalTest.ExportOptions.DestinationType = crEDTDiskFile
        crptLocalTest.Export (False)
0
 

Expert Comment

by:deguy
ID: 9874940
Glad I could help!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

919 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

18 Experts available now in Live!

Get 1:1 Help Now