Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

I want to do a batch Convert of all Crystal Report files into PDF

Posted on 2004-10-21
4
Medium Priority
?
677 Views
Last Modified: 2008-02-01
Basically I want to convert every crystal report file (.rpt) that is in a certain folder into a pdf.  I set up a VB.NET Windows form for a button click to just try with one report first, then eventually I want  change to loop through all records when I can get this one working.  

Would this be the correct way to do it?  Errors it shows for me are
CRAXDRT.Application is not defined
CRAXDRT.Report is not defined
crEDTDiskFile is not declared
crEFTPortableDocFormat is not declared

Here is the code.
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Transformation.Click
        Dim appl As New CRAXDRT.Application
        Dim rep As CRAXDRT.Report
        rep = appl.OpenReport("c:\mytest.rpt", 1)
        rep.ExportOptions.DiskFileName = "c:\pdf_report.pdf"
        rep.ExportOptions.DestinationType = crEDTDiskFile
        rep.ExportOptions.FormatType = crEFTPortableDocFormat
        rep.Export(False)
    End Sub

Please help?  Thanks ahead of time vikingg97
0
Comment
Question by:vikingg97
[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
  • 3
4 Comments
 
LVL 1

Author Comment

by:vikingg97
ID: 12374097
No one to help?
0
 
LVL 42

Accepted Solution

by:
frodoman earned 1500 total points
ID: 12374316
Is this the same question we're already working on in the Crystal forum?

frodoman
0
 
LVL 1

Author Comment

by:vikingg97
ID: 12381843
Same question but thought I might have posted wrong area.  
In reference to this question-
http://www.experts-exchange.com/Databases/Crystal_Reports/Q_21177382.html

I guess though I have another question on this one, so will post here.  

Here is what I have now which comes up with this error.  
An unhandled exception of type 'CrystalDecisions.CrystalReports.Engine.LoadSaveReportException' occurred in crystaldecisions.crystalreports.engine.dll

Additional information: Invalid report file path.

Its when it comes to this line  
'Set export options
CrExportOptions = CrReport.ExportOptions

I am not sure if its this line I am doing wrong which results in the above or not?
---Dim CrReport As New ReportDocument

Also on this line how do I send in the report name in place of justwork?  
'Set the destination path and file name
CrDiskFileDestinationOptions.DiskFileName = "c:\justwork.pdf"

This didn't work "c:\" & CRReport & ".pdf"

:::::::::::CODE:::::::::
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'Place the following name spaces at the top of the code page
        Dim fileList() As String = System.IO.Directory.GetFiles("C:\Inetpub\wwwroot\MCNetwebsite\IT_Work")

        For Each fileSource As String In fileList
            If Strings.Right(fileSource, 4) = ".rpt" Then
                'Crystal Export Code Here
                Dim CrReport As New ReportDocument
                Dim CrExportOptions As ExportOptions
                Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions
                Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions

                'Set the destination path and file name
                CrDiskFileDestinationOptions.DiskFileName = "c:\justwork.pdf"

                'Specify a page range (optional)
                CrFormatTypeOptions.FirstPageNumber = 1
                CrFormatTypeOptions.LastPageNumber = 3
                CrFormatTypeOptions.UsePageRange = True

                'Set export options
                CrExportOptions = CrReport.ExportOptions

                With CrExportOptions
                    'Set the destination to a disk file
                    .ExportDestinationType = ExportDestinationType.DiskFile
                    'Set the format to PDF
                    .ExportFormatType = ExportFormatType.PortableDocFormat
                    'Set the destination options to DiskFileDestinationOptions object
                    .DestinationOptions = CrDiskFileDestinationOptions
                    .FormatOptions = CrFormatTypeOptions
                End With

                ' Trap any errors that occur on export
                Try
                    'Export the report
                    CrReport.Export()
                Catch err As Exception
                    MessageBox.Show(err.ToString())
                End Try

            End If
        Next
    End Sub

Thanks in advance.
0
 
LVL 1

Author Comment

by:vikingg97
ID: 12383713
Any help frodoman?  Anyone?
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
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…

636 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