473,383 Members | 2,005 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Settings a default printer

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)
**/

May 10 '06 #1
4 7756
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.StringColl ection =
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

"c_shah" <sh*********@netzero.net> wrote in message
news:11**********************@y43g2000cwc.googlegr oups.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)
**/

May 10 '06 #2
Dim objprinter As Printing.PageSettings = New Printing.PageSettings()
objprinter.PrinterSettings.PrinterName = "Color Printer"

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

May 11 '06 #3
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

May 11 '06 #4
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

"c_shah" <sh*********@netzero.net> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.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

May 11 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Esmee | last post by:
Hi there, I have created an Access 2002 db which contains several reports. Some reports need to be printed on a Laserjet and others on a Labelprinter. One of my clients wants to be able to print...
1
by: Ravikanth[MVP] | last post by:
Hello, You can use the PrintDocument component to use the default printer. If you don't specify a printer to the PrintDocument object, by default, it will use the default printer. This is a...
0
by: Marco Martin | last post by:
Hi, I'm using a control that can print itself using the default printer. I want to change the default "Print Portrait" to "landscape" just before I call my control.print() method. How can I...
3
by: Rick R | last post by:
We need to change the paper size for the default printer before printing a PDF file from within a VB.Net application. printDocument printerSettings is not appropriate as there is no document to...
3
by: millind | last post by:
I have a small issue. I have a html page which i need to print it legal size. My default printer setting is letter. How can i set a script which will print just this page in legal without change...
1
by: i8mypnuts | last post by:
Could someone please help? I am using the 'defaultprt.zip' tool provided by Ken Getz to change the default printer via VBA code (code below). My problem is that once the default printer has been...
4
by: David C. Barber | last post by:
my.computer.printers.defaultprinter doesn't exist in 2005, despite the plethora of examples still out on the web detailing its use. So how can I determine a person's default printer using ASP 2?...
3
by: brianflannery | last post by:
Greetings all! My problem is this. I've installed a new printer on my computer. This is the "default printer" for access. Now, some of my reports, which were working fine with the old printer,...
4
by: nano2k | last post by:
Hello I need to display and then automatically print a PDF file. I'm using AxAcroPDF to display the PDF. AxAcroPDF class has a very good method: printAll(). The only thing is that I need to...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.