Solved

Exporting Crystal Report to PDF upon Form loading in VB

Posted on 2003-12-03
8
2,470 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Suggested Courses

751 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