Solved

Exporting Crystal Report to PDF upon Form loading in VB

Posted on 2003-12-03
8
2,464 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
CRRuntime - Alerts 9 45
Not Exists 3 53
Crystal Report for VS2013 17 42
Help with a Crystal Report Formula - remove time 5 13
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

746 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

13 Experts available now in Live!

Get 1:1 Help Now