Home All Groups Group Topic Archive Search About

Settings a default printer

Author
10 May 2006 9:27 PM
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)
**/

Author
10 May 2006 10:23 PM
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

--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com



Show quoteHide quote
"c_shah" <shah.chi***@netzero.net> wrote in message
news:1147296473.292215.194560@y43g2000cwc.googlegroups.com...
> 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)
> **/
>
Author
11 May 2006 1:08 PM
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"
Author
11 May 2006 1:27 PM
c_shah
PrinterSettings.PrinterName  is not a reliable method to set a default
printer.

/*
Dim wshnetwork As Object = CreateObject("WScript.Network")
Dim printerpath As Object = "TIFF Image Printer 7.0"
wshnetwork.SetDefaultPrinter(printerpath)
*/
but the above is not a managed code

I found also other ways
http://emoreau.s2i.com/Articles/200503/EricMoreau1.html
Author
11 May 2006 4:03 PM
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.

--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com



Show quoteHide quote
"c_shah" <shah.chi***@netzero.net> wrote in message
news:1147354022.700458.198170@u72g2000cwu.googlegroups.com...
> PrinterSettings.PrinterName  is not a reliable method to set a default
> printer.
>
> /*
> Dim wshnetwork As Object = CreateObject("WScript.Network")
> Dim printerpath As Object = "TIFF Image Printer 7.0"
> wshnetwork.SetDefaultPrinter(printerpath)
> */
> but the above is not a managed code
>
> I found also other ways
> http://emoreau.s2i.com/Articles/200503/EricMoreau1.html
>