vikingg97
asked on
I want to do a batch Convert of all Crystal Report files into PDF
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.DiskFile Name = "c:\pdf_report.pdf"
rep.ExportOptions.Destinat ionType = crEDTDiskFile
rep.ExportOptions.FormatTy pe = crEFTPortableDocFormat
rep.Export(False)
End Sub
Please help? Thanks ahead of time vikingg97
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
rep.ExportOptions.DiskFile
rep.ExportOptions.Destinat
rep.ExportOptions.FormatTy
rep.Export(False)
End Sub
Please help? Thanks ahead of time vikingg97
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Same question but thought I might have posted wrong area.
In reference to this question-
https://www.experts-exchange.com/questions/21177382/I-want-to-do-a-batch-Convert-of-all-Crystal-Report-files-into-PDF.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.CrystalR eports.Eng ine.LoadSa veReportEx ception' occurred in crystaldecisions.crystalre ports.engi ne.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
CrDiskFileDestinationOptio ns.DiskFil eName = "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.GetFil es("C:\Ine tpub\wwwro ot\MCNetwe bsite\IT_W ork")
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 CrDiskFileDestinationOptio ns As New DiskFileDestinationOptions
Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions
'Set the destination path and file name
CrDiskFileDestinationOptio ns.DiskFil eName = "c:\justwork.pdf"
'Specify a page range (optional)
CrFormatTypeOptions.FirstP ageNumber = 1
CrFormatTypeOptions.LastPa geNumber = 3
CrFormatTypeOptions.UsePag eRange = True
'Set export options
CrExportOptions = CrReport.ExportOptions
With CrExportOptions
'Set the destination to a disk file
.ExportDestinationType = ExportDestinationType.Disk File
'Set the format to PDF
.ExportFormatType = ExportFormatType.PortableD ocFormat
'Set the destination options to DiskFileDestinationOptions object
.DestinationOptions = CrDiskFileDestinationOptio ns
.FormatOptions = CrFormatTypeOptions
End With
' Trap any errors that occur on export
Try
'Export the report
CrReport.Export()
Catch err As Exception
MessageBox.Show(err.ToStri ng())
End Try
End If
Next
End Sub
Thanks in advance.
In reference to this question-
https://www.experts-exchange.com/questions/21177382/I-want-to-do-a-batch-Convert-of-all-Crystal-Report-files-into-PDF.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.CrystalR
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
CrDiskFileDestinationOptio
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.GetFil
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 CrDiskFileDestinationOptio
Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions
'Set the destination path and file name
CrDiskFileDestinationOptio
'Specify a page range (optional)
CrFormatTypeOptions.FirstP
CrFormatTypeOptions.LastPa
CrFormatTypeOptions.UsePag
'Set export options
CrExportOptions = CrReport.ExportOptions
With CrExportOptions
'Set the destination to a disk file
.ExportDestinationType = ExportDestinationType.Disk
'Set the format to PDF
.ExportFormatType = ExportFormatType.PortableD
'Set the destination options to DiskFileDestinationOptions
.DestinationOptions = CrDiskFileDestinationOptio
.FormatOptions = CrFormatTypeOptions
End With
' Trap any errors that occur on export
Try
'Export the report
CrReport.Export()
Catch err As Exception
MessageBox.Show(err.ToStri
End Try
End If
Next
End Sub
Thanks in advance.
ASKER
Any help frodoman? Anyone?
ASKER