How to invoke a Crystal Report Programatically through a VB 6 Activex Component
Hello Gurus,
I am new to Crystal reports. I am given the task of running a crystal report in a specified path without using forms or any user control. I need your help as how to proceed with the same. kindly give me the directions. I have CR XI installed in my machine.
Re: How to invoke a Crystal Report Programatically through a VB 6 Activex Component
I do not use crystal so I can not be sure about this but I would think shell() may be your answer.
Re: How to invoke a Crystal Report Programatically through a VB 6 Activex Component
Which version of Crystal? The one that came with VB6?
Re: How to invoke a Crystal Report Programatically through a VB 6 Activex Component
I am using Crystal reports 11 Developer edition, not the one that came with VB. I have figured out how to export the report to a PDF file but I have no idea as how to launch the report through VB code.
The following code snippet I got from the internet and made some changes. this is working fine.
Public Function ExportToPDF(ByVal ReportName As String)
Dim strRptfile, strExportfile
Dim RetValue
Dim strDate
Dim objCRRpt
Dim objCRApp
WriteLog ("ExportRPT: " & ReportName)
strDate = Year(Now()) & "-" & Right("0" & Month(Now()), 2) & "-" & Right("0" & Day(Now()), 2)
RetValue = ""
strRptfile = UCase(ReportName)
strExportfile = Replace(strRptfile, ".RPT", "-" & strDate & ".PDF")
Set objCRApp = CreateObject("CrystalRunTime.Application")
Set objCRRpt = objCRApp.OpenReport(strRptfile)
With objCRRpt
With .ExportOptions
.FormatType = crEFTPortableDocFormat
.PDFExportAllPages = True
.DiskFileName = strExportfile
.DestinationType = crEDTDiskFile
.UseReportDateFormat = True
.UseReportNumberFormat = True
End With
.Export (False)
RetValue = strExportfile
End With
ExportToPDF = RetValue
End Function
Now how do i actually launch the report for printing on a printer.