Settings a default printer

C

c_shah

How to change and set default printer using Visual Basic 2005
The following works within my VB 2005 application but does any one have
better alternative.

/****
Dim wshnetwork As Object = CreateObject("WScript.Network")
Dim printerpath As Object = "TIFF Image Printer 7.0"
wshnetwork.SetDefaultPrinter(printerpath)
**/
 
V

vbnetdev

Private Sub GetMe()
Dim a As New Printing.PageSettings()
TextBox1.Text = a.PrinterSettings.PrinterName()
End Sub

'this will get a list of every printer setup on the current machine
Private Sub ListMe()
Dim a As New Printing.PageSettings()
Dim b As System.Drawing.Printing.PrinterSettings.StringCollection =
Printing.PrinterSettings.InstalledPrinters
Dim X As Integer
For X = X To b.Count - 1
ListBox1.Items.Add(b.Item(X))
Next
End Sub

'this will make the selected printer the default printer
Private Sub ChangeMe()
Dim a As New Printing.PageSettings()
a.PrinterSettings.PrinterName = ListBox1.SelectedItem
End Sub
 
C

c_shah

Dim objprinter As Printing.PageSettings = New Printing.PageSettings()
objprinter.PrinterSettings.PrinterName = "Color Printer"

is not changing my default printer (Black & White) to "Color Printer"
 
V

vbnetdev

If you had wanted to change the settings of your default printer instead of
setting the default printer itself you should have said so. However I am
glad you found your solution.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top