printing to non-default printer 
Author Message
 printing to non-default printer

I want the user to be able to choose from a list of printers (I create the
list by parsing through the printers collection).  I then want to be able to
print to that printer.  I know that I have to set a printer to be the default
printer if I want to use the Printer object.  And I also know that there's a
way to print to the non-default printer by using the hdc properties.  But, I
don't know how to do that.  This is why I'm writing.  Does anyone know how to
do this?

BONUS question:  I would like to get Excel97 to use the exact same printer
after I bring up Excel with the Excel object.

Thanks!
Kevin

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Kevin McCracken

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-



Mon, 26 Mar 2001 03:00:00 GMT  
 printing to non-default printer
Try using the Common Dialog with action property = 5, this will allow for
printer selection. It sets the Printer object and properties for you.



Quote:
> I want the user to be able to choose from a list of printers (I create
the
> list by parsing through the printers collection).  I then want to be able
to
> print to that printer.  I know that I have to set a printer to be the
default
> printer if I want to use the Printer object.  And I also know that
there's a
> way to print to the non-default printer by using the hdc properties.
But, I
> don't know how to do that.  This is why I'm writing.  Does anyone know
how to
> do this?

> BONUS question:  I would like to get Excel97 to use the exact same
printer
> after I bring up Excel with the Excel object.

> Thanks!
> Kevin

> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

> Kevin McCracken

> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-



Mon, 26 Mar 2001 03:00:00 GMT  
 printing to non-default printer
I tried to change the System's default printer in code (VB4) and failed.
Writing to the registry key does not do the job either. The only thing
that did work was displaying the Common Dialog box and ask the user to
change the default printer (before printing a Crystal Report). The
drawback for this solution is that the System's default printer changes
globally and I wasn't able to reset (in code) the printer after the
printing to what it was.

Regards
Sleiman



Mon, 26 Mar 2001 03:00:00 GMT  
 printing to non-default printer

this is what I did for print Cystal reports to a non defult printer .

i made a form up so the user could select what printer to use .
this only changes the printer for you applilication and not the system.

"moduleprinter.bas"
Public CurPrinterPort As String
Public CurPrinterName As String
Public PrnDriverName As String

====================
"Form1(printerselect.frm)
combo box
2 command buttons  ...   (select printer) and (cancle)

'CODE
Private Sub Command2_Click()
Unload Me

End Sub

Private Sub Form_Load()
Dim printerobject As Printer
Dim element As Integer
Dim printerdriver

Combo1.Clear
For Each printerobject In Printers
Combo1.AddItem printerobject.DeviceName

If Printer.DeviceName = printerobject.DeviceName Then

  Combo1.ListIndex = element
  Combo1.SelStart = 0
  Combo1.SelLength = 99
End If
element = element + 1
Next printerobject

End Sub

Private Sub Command1_Click()
'The in the OK command button you use the line:
SelectedPrinter = Combo1.ListIndex
'printerdriver = printerobject.DriverName
 a = Printer.Port

Set Printer = Printers(Combo1.ListIndex)
CurPrinterPort = Printer.Port
CurPrinterName = Printer.DeviceName
PrnDriverName = Printer.DriverName & ".dll"
Unload Me

End Sub

'============================

then when you want to actually print the report  you
set this params ..
like from a button ..

printbutton_(click)
CrystalReport1.printerdriver = PrnDriverName
    CrystalReport1.PrinterName = CurPrinterName
    CrystalReport1.PrinterPort = CurPrinterPort
    CrystalReport1.WindowControls = True
    CrystalReport1.Destination = 0
    CrystalReport1.Action = 1

hope this helps ...



Tue, 27 Mar 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Q: Printing report on non-default printer w/o user selecting printer

2. Printer.Print on non-default printer

3. printer default to non-default printer

4. How selecting a (non-default) printer for printing a report

5. Printing to non-default printer

6. How do I Print to non-default printer in VB5

7. Printing to non-default printer

8. Help w/ printing to non-default printer

9. Print on a non-default printer

10. Print to non-default printer

11. Macro that selects printer and prints doc also changes default printer

12. Printing to a printer that is NOT the default printer

 

 
Powered by phpBB® Forum Software