CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2010
    Posts
    2

    Unhappy 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.

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    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.
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: How to invoke a Crystal Report Programatically through a VB 6 Activex Component

    Which version of Crystal? The one that came with VB6?
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  4. #4
    Join Date
    Apr 2010
    Posts
    2

    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured