Results 1 to 9 of 9

Thread: Exporting PDF format Crystal Report

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2004
    Posts
    6

    Question Exporting PDF format Crystal Report

    I am using VB6 and Crystal Report 9.0.
    I need to export a Crystal Report file into a PDF file format by simply a click at an button on the VB form.
    How can I code to export such file?

    Thanks very much for the help!!!

  2. #2
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: Exporting PDF format Crystal Report

    Here is the code form one of my reports that extracts to a PDF fdile.

    --/

    Set Report = crxApplication.OpenReport("Z:\DAD\CertificateofComplianceB.rpt", 1)
    For Each crxDatabaseTable In Report.Database.Tables
    crxDatabaseTable.ConnectionProperties("user id") = "sa"
    crxDatabaseTable.ConnectionProperties("Password") = myPasswordTechniSQL
    Next crxDatabaseTable
    Report.ExportOptions.FormatType = crEFTPortableDocFormat
    Report.ExportOptions.DiskFileName = "C:\Certificate_of_Compliance_" & jobinx & ".pdf"
    Report.ExportOptions.DestinationType = crEDTDiskFile
    Report.Export False

    --/

  3. #3
    Member
    Join Date
    Nov 2004
    Location
    KS, USA
    Posts
    34

    Re: Exporting PDF format Crystal Report

    Sorry stanleyccs, for hijacking your thread but this may help you too because it is very similar to what you are doing.


    Hi Pasvorto,

    I am doing something very similar except I am exporting to HTML.
    I am interested in your connection method.
    I tried using your code but I am not familiar enough with the VB Code.
    I can get my code to export a generic report that does not login to the SQL database but when I try my report the login portion fails.
    I think my problem might be with the definition.

    Here is my code:

    Private Sub Command1_Click()

    Dim crxApp As CRAXDRT.Application
    Dim crxRpt As CRAXDRT.Report
    Dim crxDatabaseTable As CRAXDRT.DatabaseTable

    Set crxApp = New CRAXDRT.Application
    Set crxRpt = crxApp.OpenReport("H:\VB6\SuSched\SuSched.rpt", 1)

    For Each crxDatabaseTable In Report.Database.Tables
    crxDatabaseTable.ConnectionProperties("user id") = "sa"
    crxDatabaseTable.ConnectionProperties("Password") = test
    Next crxDatabaseTable

    With crxRpt.ExportOptions
    .FormatType = CRAXDRT.CRExportFormatType.crEFTHTML40
    .DestinationType = CRAXDRT.CRExportDestinationType.crEDTDiskFile
    .HTMLFileName = "H:\VB6\SuSched\SuSched.html"
    End With

    crxRpt.Export (False)
    Set crxRpt = Nothing
    Unload Form1

    End Sub


    Edit: I forgot to tell you I would like to use an odbc connection.
    Thanks - Jeff
    Last edited by rothjm; Jan 7th, 2005 at 04:33 PM.

  4. #4
    Member
    Join Date
    Nov 2004
    Location
    KS, USA
    Posts
    34

    Re: Exporting PDF format Crystal Report

    I got it to work for me by adding:

    With crxRpt.Database.Tables(1).ConnectionProperties
    .Item("DSN") = "TEST"
    .Item("Database") = "TEST_DB"
    .Item("User ID") = "TESTUSER"
    .Item("Password") = "PASSWORD"
    End With

    Thanks

  5. #5
    New Member
    Join Date
    Feb 2005
    Posts
    1

    Re: Exporting PDF format Crystal Report

    What is the component or preferences needed to use
    this command (ConnectionProperties) ??

  6. #6
    Member
    Join Date
    Nov 2004
    Location
    KS, USA
    Posts
    34

    Re: Exporting PDF format Crystal Report

    I think it is the Crystal Reports ActiveX.
    I am not 100% sure, I still a rookie.
    I have these three references:

    CRAXDRT (ActiveX)
    CrystalDecisions.CrystalReports.Engine
    CrystalDecisions.Shared

    Crystal Reports Developer V 10 & VB.Net is what I am using.

  7. #7
    Member
    Join Date
    Nov 2004
    Location
    KS, USA
    Posts
    34

    Post Re: Exporting PDF format Crystal Report

    Actually, I changed it to this (sorry if some lines wrap):


    'Declare ActiveX objects
    Dim crxApp As CRAXDRT.Application
    Dim crxRpt As CRAXDRT.Report
    Dim crxDatabaseTable As CRAXDRT.DatabaseTable

    'Used for connection to the SQL Server using the ODBC DSN
    Dim lstrDataSource As String
    Dim lstrCatalog As String
    Dim lstrUser As String
    Dim lstrPassword As String
    Dim lstrLocation As String
    Dim lstrTableName As String

    'Turn on hourglass
    System.Windows.Forms.Cursor.Current = system.Windows.Forms.Cursors.WaitCursor

    crxApp = New CRAXDRT.Application

    'Set Logon properties
    lstrDataSource = "MY_DSN"
    lstrCatalog = "MY_DB"
    lstrUser = "MY_USERNAME"
    lstrPassword = "test"

    'Open the report to export
    crxRpt = crxApp.OpenReport("\\HPTLWF01\DPRTMNTS$\Information_ Systems\Visual Basic Progs\ExportSuSched.NET\SuSched.rpt", 1)
    crxRpt.DiscardSavedData() 'We want a fresh query

    'Connect to the database using ODBC connection
    For Each crxDatabaseTable In crxRpt.Database.Tables
    lstrTableName = crxDatabaseTable.Location
    crxDatabaseTable.ConnectionProperties.DeleteAll() 'Clear existing connection properties
    crxDatabaseTable.ConnectionProperties.Add("DSN", lstrDataSource) 'Set connection properties
    crxDatabaseTable.ConnectionProperties.Add("Database", lstrCatalog)
    crxDatabaseTable.ConnectionProperties.Add("User Id", lstrUser)
    crxDatabaseTable.ConnectionProperties.Add("Password", lstrPassword)
    Next crxDatabaseTable 'Loop through all the tables in the report


    .....

  8. #8
    Junior Member
    Join Date
    Feb 2006
    Posts
    27

    Re: Exporting PDF format Crystal Report

    How do I get VB to recognise CRAXDRT. If I do Dim crxApp As CRAXDRT.Application it says that craxdrt is undeclared

  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Exporting PDF format Crystal Report

    You need to add a reference to Crystal Reports x.x ActiveX Designer Run Time Library.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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