I need a way to switch the selected default from one installed/local printer to another installed/network printer transparently. I would like for it to act like a physical switch box. Is there an easy way to do this?<br>
<br>
Thanks!
Here is the example from vb help printer object.<br>
Dim X As Printer<br>
For Each X In Printers<br>
If X.Orientation = vbPRORPortrait Then<br>
' Set printer as system default.<br>
Set Printer = X<br>
' Stop looking for a printer.<br>
Exit For<br>
End If<br>
Next
Just slightley different....<br>
<br>
Dim X as Printer<br>
For Each X in Printers<br>
If X.DeviceName = "Name of Printer" Then ' ie "WINFAX" <br>
Set Printer = X<br>
Exit For<br>
End If<br>
Next<br>
You have to modify the registry via an API to do this.
I have created a program that reads the current default printer, modifies it to my selection, starts an app, waits for the app to end and then brings the default printer to the original one.
I won't put the whole code in here but if you want it, just send an e-mail to sebasd@fenplast.com and i'll be happy to give it to you.
If you want to do it on your own, the API's are:
getprofilestring and writeprofilestring.
Which code submission did you use? [bb]thewhip[/bb]'s or [bb]markeymark[/bb]s?
thewhip's is, as they point out, a direct lift from the VB help file, and only sets the default printer to the first one that is set to print in portrait mode. This probably isn't all that useful to you, and could well give the impression that the code isn't doing anything
markeymark's is a modofied version that should allow you to set the default to a named printer (assuming you know that name). It should work fine (even under NT Server)
Note, however, that this technique merely changes the default printer for the VB application; it is [bb]not[/bb] a system-wide change. To affect that you have to resort to some minor registry work as mentioned by [bb]sebpas[/bb]
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.