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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print to not default printer

Status
Not open for further replies.

Eli20

Programmer
Oct 30, 2003
119
MX
hi, i have a program in vb6.0 and i use crystal reports 8.0 to generate my reports. i use a CRViwer to see them in my program, my database in MSSQL 7.0

how can i print the report not the default printer? how can set the printer i need in my program by code? what do i need to set??

thank you very much

Eli
 
Are you trying to change the printer before opening up the viewer, or are you wanting to print the report apart from the viewer?

To change the printer prior to opening the viewer, use vb's common dialog control, as in:

CommonDialog1.ShowPrinter

Or, Loop through the Printers collection, selecting the desired printer:

Dim prt as Printer

For each prt in Printers
If prt.DeviceName = Trim(MyFrom.cboPrinters.Text) Then
Set Printer = prt
Exit For
End If
Next


To print the report to a printer without opening the viewer, use code similar to the following (again, assuming the user is given a form to select the printer and then click on a command butto to start the print job):

Dim prt as Printer

For Each prt In Printers
If prt.DeviceName = Trim(MyFrom.cboPrinters.Text) Then
Set Printer = prt
report.SelectPrinter prt.DriverName, prt.DeviceName, prt.Port
'if you need to change the paper orientation, do it here
'report.PaperOrientation = crLandscape
Exit For
End If
Next

'The False argument means don't prompt the user for the number of copies to print and starting page number; use True if you want the user to choose those settings
report.PrintOut False
 
thank You, i think it will help!

Eli
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top