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

Print and not using the standard printer 2

Status
Not open for further replies.

Denaeghel

Programmer
Apr 23, 2001
61
BE
How can I print files without using the Printer dialog Box and not using the standard printer.
 

This should do it:

------------------------------------------------------------
Dim P As Printer, OldP As Printer
OldP = Printer
For Each P In Printers
If P.DeviceName = [the one you want] Then
Set Printer = P
Exit For
End If
Next
'do your printing here
Set Printer = OldP
------------------------------------------------------------

Sunaj
 
Ok, it works but I get an error by SET PRINTER = OLDP. Error 13 - TYPE MISMATCH, but by SET PRINTER = P, I get no error.

What can I do wrong??? I just declare P and Old P as Public and use them in a another Procedure.

Could you say what I have to do

Thanks
 
Hi,

Sorry my mistake.

It actuallly not neccesary to change back to the old printer because as soon at the program end this is done automatically.

If you want to do it anyway:

-----------------------------------------------------------
Dim P As Printer, OldP as string
OldP = Printer.DeviceName
For Each P In Printers
If P.DeviceName = "\\HOEK\castle" Then
Set Printer = P
Exit For
End If
Next
'do your printing here
For Each P In Printers
If P.DeviceName = OldP Then
Set Printer = P
Exit For
End If
Next
-----------------------------------------------------------

*:->* Sunaj
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top