|
-
Jan 2nd, 2005, 11:10 PM
#1
Thread Starter
New Member
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!!!
-
Jan 3rd, 2005, 07:58 AM
#2
PowerPoster
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
--/
-
Jan 7th, 2005, 04:11 PM
#3
Member
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.
-
Jan 7th, 2005, 04:51 PM
#4
Member
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
-
Feb 7th, 2005, 03:25 AM
#5
New Member
Re: Exporting PDF format Crystal Report
What is the component or preferences needed to use
this command (ConnectionProperties) ??
-
Feb 7th, 2005, 09:31 AM
#6
Member
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.
-
Feb 7th, 2005, 09:43 AM
#7
Member
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
.....
-
Feb 21st, 2006, 05:54 PM
#8
Junior Member
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
-
Feb 21st, 2006, 06:00 PM
#9
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|