473,662 Members | 2,352 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Changing Printers in Visual Basic

Bob
I am looking for a way to change an individuals (users) default printer to another printer. Print a file and then reset back to the users original printer. Any suggestions?
Nov 20 '05 #1
1 862
Hi,

Add a reference to system.manageme nt.dll

Dim moReturn As Management.Mana gementObjectCol lection

Dim moSearch As Management.Mana gementObjectSea rcher

Dim mo As Management.Mana gementObject

moSearch = New Management.Mana gementObjectSea rcher("Select * from
Win32_Printer")

moReturn = moSearch.Get

For Each mo In moReturn
Dim objReturn As Object
Debug.WriteLine (mo("Name"))
mo.InvokeMethod ("SetDefaultPri nter", objReturn)
Next
Ken
-----------------------
"Bob" <an*******@disc ussions.microso ft.com> wrote in message
news:08******** *************** ***********@mic rosoft.com...
I am looking for a way to change an individuals (users) default printer to
another printer. Print a file and then reset back to the users original
printer. Any suggestions?

Nov 20 '05 #2

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

Similar topics

2
4090
by: Karl E. Taylor | last post by:
Could someone point me in the direction of a good example of coding report printing from database tables through VB? I have 5 tables that I need to run a report from. They are actually very small, 1 - 8 columns wide, containing from 1 - 24 records in each table. So by my estimation, the whole database, should print to a single sheet of paper, if formated properly. Problem is, in all the VB5, 6 books and tutorial sites that I've got...
16
48867
by: cyranoVR | last post by:
This is the approach I used to automate printing of Microsoft Access reports to PDF format i.e. unattended and without annoying "Save As..." dialogs, and - more importantly - without having to use a commercial program such as Adobe Acrobat and its associated API. The technique uses Ghostscript and Redirection Port Monitor - two free programs for creating PDF documents provided free by Russell Lang. The actual automation requires VBA...
6
10483
by: Ioannis Demetriades | last post by:
Hi, I need to change the printer's font to "control" -a printer font, and then send a sequence of characters to the printer. My problem is that I cannot change the printer's font. Can this be done without API calls? Thanks Ioannis
3
2125
by: Panos | last post by:
Hi all, I am trying to print a report in A4 paper, but my printer's default paper is different (Letter 8.5 x 11 inches). So when i print, a significant part of the paper remains blank, because of the different margins. Does anyone know how to programmatically change the printer's default paper? Almost all properties of the Printersettings Class on this matter are ReadOnly. Thank u Panos
2
932
by: James | last post by:
Hello people, i wanna learn Visual Basic.net & Asp.net (i was using ASP3 before (with VB language)) So i have a book (Visual Basic.net version 2003)(http://www.microapp.com/fiche_technique.cfm?ref_produit=4340) i only read few page of it because of no time :-( now i have time to read 2 3 book of programing and what the best thing.
2
2831
by: Jeff Williams | last post by:
I am looking for a way to get the list of printers and there port name so I can populate a combobox. What I need to do is get the printer name and if it is a network printer the path and share name. Place the printer name in a combobox and the share name as a value in the combo box which I can then pass to another .net application. I would appreciate any help or links to code which would show how to do
9
27995
spider1916
by: spider1916 | last post by:
I am using the common dialog control to allow my users to select any printer available to them. The code I am using keeps changing the selected printer to the default printer............I don't want that. I can't find anything with a propar salution to my problem. I JUST WANT TO PRINT A REPORT!!!!!!! No setting needs to be changed, ever. I only want to get the selected printer from the dialog and print to it. This seems to allow me...
0
1577
by: Ravigwipro | last post by:
Hi, I m able to get the printers object to know what are the printers had been installed and all. here my requirement is i have to write a data from VB to MS Word. for the page setup i have to get printer info. problem here i m facing is , i m getting the printer info and am able to write the complete document in that case it is working fine..but while generation of document if it gets fail due to some runtime error, in the immediate run...
4
6069
by: Luqman | last post by:
I am using Visual studio 2008 and ASP.Net 3.5 How can I fill a combo with List of Local Printers, installed on Client Machine ? If I have to buy any Activex Control from Internet, please do recommend. Best Regards, Luqman
7
4328
by: DAHMB | last post by:
Why won't this work? I am using access 2007. Private Sub btnPrint_Click() Dim strDefaultPrinter As String ' get current default printer. strDefaultPrinter = Application.Printer.DeviceName ' switch to printer of your choice:
0
8856
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8762
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7365
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6185
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5653
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4179
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1992
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1747
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.