Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Exporting Crystal Report to PDF upon Form loading in VB

Posted on 2003-12-03
8
Medium Priority
?
2,474 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 101

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
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 

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
 

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 400 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

824 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