Home » Visual StudioRSS

How to Export a Crystal Report to a PDF file Programmatically in vb.net

i try below code


Imports CrystalDecisions.CrystalReports.Engine

Imports CrystalDecisions.Shared


'In Class

Dim customerReport As ReportDocument

customerReport = New ReportDocument()

Dim reportPath As String = Application.StartupPath & "\" & "CustMonthly.rpt"   ' I saved my report in the "\BIN\Debug" dir


Dim strPath As String

Dim strFileName As String

'Filename made up of customer number, year, month

strFileName = strCust & "_" & intYear.ToString & "_" & intMonthStart.ToString

'Path to save pdf report to and filename saved as

strPath = Application.StartupPath & "\reports\" & strFileName & ".pdf"

customerReport.ExportToDisk(ExportFormatType.PortableDocFormat, strPath)


and my code is 

szCurrDir = CurDir.ToString

            'In Class

            Dim customerReport As ReportDocument

            customerReport = New ReportDocument()

            Dim reportPath As String = szCurrDir & "\Other Report\repRD_Excel_Genrat.rpt"   ' I saved my report in the "\BIN\Debug" dir


            Dim strPath As String

            Dim strFileName As String

            'Filename made up of customer number, year, month

            strFileName = "Try"

            'Path to save pdf report to and filename saved as

            strPath = szCurrDir & strFileName & ".pdf"

            customerReport.ExportToDisk(ExportFormatType.PortableDocFormat, strPath)



Error is................ Missing parameter values.

plz help me anyone..............plz





2 Answers Found


Answer 1

Dear Sam,

I've checked your code, it contains 2 small errors. The reason this is not working is probably because the file "CustMonthly.rpt" is not in the debug directory or because the "Reports" folder does not exist. To fix the first, go to the properties of the *.rpt file, then set "Copy To Output Directory " to "Copy Always ". If you expand your code as demonstrated below, it will work. If this was helpfull and or the answer, please mark it as such.




Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.SharedImports System.IO
PublicClass SomeReport
  PrivateSub CheckOutPutFolder()
    TryIfNew System.IO.DirectoryInfo(Path.Combine(Application.StartupPath, "Reports")).Exists = FalseThen
        Directory.CreateDirectory(Path.Combine(Application.StartupPath, "Reports"))
      EndIfCatch ex As Exception
    EndTryEndSubPublicSub RunMyReport()
    If System.IO.File.Exists(Path.Combine(Application.StartupPath, "CustMonthly.rpt")) = TrueThenDim customerReport AsNew ReportDocument()
      Dim reportPath AsString = Path.Combine(Application.StartupPath, "CustMonthly.rpt")
      With customerReport
        .ExportToDisk(ExportFormatType.PortableDocFormat, Path.Combine(Application.StartupPath, "MyReport.pdf"))
      MessageBox.Show("Your rpt was not found in the following folder: " & vbCrLf & Application.StartupPath)



Answer 2

Hi Sam,

I am moving this thread to "Crystal Reports for Visual Studio" forum for better support.


Best Regards,


<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Follow us on Twitter