|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Settings a default printerHow 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) **/ 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 -- Show quoteHide quoteGet a powerful web, database, application, and email hosting with KJM Solutions http://www.kjmsolutions.com "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) > **/ > Dim objprinter As Printing.PageSettings = New Printing.PageSettings()
objprinter.PrinterSettings.PrinterName = "Color Printer" is not changing my default printer (Black & White) to "Color Printer" 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 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. -- Show quoteHide quoteGet a powerful web, database, application, and email hosting with KJM Solutions http://www.kjmsolutions.com "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 > |
|||||||||||||||||||||||