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!

Duplex printing report from VB 6

Status
Not open for further replies.

PCJock

Programmer
Feb 12, 2002
16
0
0
US
I can not get my crystal 8.5 report to print in duplex mode programmatically.
The printer is a duplex printer. I can step through and see the properties of the report object being modified by my code. I can print just fine if I use "Report.PrinterSetup Me.hWnd". But I have to manually choose duplex mode in the printer setup each time. The user does not need to see the preview of the report either. Am I missing something?

Here is the my code:

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!
 
Why not use the .PrinterDuplex property of the report object...

PrinterDuplex - CRPrinterDuplexType. Gets or sets the current printer duplex option. Read/Write Can be written only when formatting idle.

crPRDPDefault 0
crPRDPHorizontal 3
crPRDPSimplex 1
crPRDPVertical 2



Cheers,

SurfingGecko
Home of Crystal Ease
 
SurfingGecko,
I am already using the PrinterDuplex property as shown in my previous code posting. It does not seem to be working like it should be.

Any more ideas? Maybe its a Crystal bug?.

Thanks

PCJock
 
I wanted to update everyone. I solved my problem. It still does not work programatically with VB. But, I found another solution. I had our server admin create a new printer that pointed to the same printer. We then modified the default properties, so that the new printer would always print in duplex mode. We just gave the new printer the same name as the old one, but added a suffix of "Duplex". Works great!
 
Bit of an old thread I know, but I had the same problem and came across it in google.

Found that if I set the printerduplex property just before I call the printout method it works - if I set printerdeuplex then do something else with the report (i.e. set a parameter in my case) it loses it.
 
I am working on a similar situation involving CR9 and VB6.

Will the code in the very first entry on this thread work in my situation?

Please advise. Thanks.
 
I am not familiar with version 9 of CR. But, unless it has changed from 8.5 to 9, it should work. I would try what telescopi mentioned in his post. I think we tried that and had no luck.
 
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 (sql server and database programming). I would like to use your code to print a report programatically from either crystal 8 or 9 and from a ctd2000 application. The ctd can print to crystal but i find it limiting specially in passing variables to apps. What libraries do i need to include in the code above to be able to print reports from a vb app using the code above. My idea, with your permission to use your code, 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 you help. I am at end of my rope trying to resolve this proble with very little knowledgde of vb or crystal.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top