How can I make a printer default printer given its name.
for example, "HP LaserJet MP/6". There are many printers.
Printable View
How can I make a printer default printer given its name.
for example, "HP LaserJet MP/6". There are many printers.
It will only be the default while your program is running. Then it will revert.
You could save the value, and set it every time your program runs, though.
This will set the default printer permanatly.VB Code:
' Add a reference to the Windows Script Host Object Model Private Sub Command1_Click() Dim wshobj As WshNetwork ' Create a new reference to the above-mentioned object library. ' Call on the "SetDefaultPrinter" method to do exactly that. Set wshobj = New WshNetwork wshobj.SetDefaultPrinter ("PrinterNameHere") ' Unload the no-longer required object from the computer's memory. Set wshobj = Nothing End Sub
Take a look at this sample (and some others that you can easily find there) by Randy Birch:
Setting Default Printer .