Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing Crystal Rpt 8 or 9 from VB Programatically

Status
Not open for further replies.

khnp

Programmer
Oct 15, 2003
5
0
0
US
I looked at the snipet of code placed by pcjock and hope this is a solution to a problem i am facing. I am by no means a crystal or vb expert, I will qualify myself as a novice, (sql server and database programming been the areas ). I would like to use this code, as a sample, to develop a small app to be called from ctd 2000 application to print a crystal report programatically from either crystal 8 or 9. The ctd can print to crystal but i find it limiting specially in passing variables to apps, the biggest problem been date variables. What libraries do i need to include in the code below to be able to print reports from a vb app. My idea, with your permission to use his code as a guide, is to initialize the printer, either normal printer or amyuni pdf converter in the vb app, pass parameters to the app, print the report and then release the printer driver. Can anybody help. I am at end of my rope trying to resolve this problem with very little knowledgde of vb or crystal.

This snippet is by pcjock ( a contributor to this site and it was posted on may 12 2003 in the programmer's forum).

Dim Viewer AS CRAXDRT.Application
Dim Report AS CRAXDRT.Report
Set Viewer = New CRAXDRT.Application
Set Report = Viewer.OpenReport("XYZ.rpt")
Report.SelectPrinter pDriverName, pPrinterName, pPortName
Report.PaperOrientation = crLandscape
Report.PrinterDuplex = crPRDPHorizontal
Report.ParameterFields.Item(1).AddCurrentValue 52446
Report.ParameterFields.Item(2).AddCurrentValue -1
Report.DisplayProgressDialog = True
Report.Database.Tables(1).SetLogOnInfo "MyServer", "MyDatabase", "User", "Pwd"
Report.PrintOut True
Set Report = Nothing
Set Viewer = Nothing


 
Thanks a lot synapsevampire and pcjock. I followed the example and the snipet of code and was able to solve the problem I was facing. An added bonus came with while doing it. I created an interface for Amyuni PDFConverter that will allow me to bypass CTD 2000 in favor of VB.net while printing PDF files programatically.

Again thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top