Solved

Set a printer as the default printer

Posted on 2001-06-13
3
224 Views
Last Modified: 2010-05-02
How is it possible to set (by code and not using a common dialog) a printer as the default printer?
0
Comment
Question by:BrainStorm
3 Comments
 
LVL 5

Accepted Solution

by:
GeoffKell earned 50 total points
ID: 6184785
0
 
LVL 1

Expert Comment

by:ahmadpj
ID: 6184884
This is the answer:
add a listbox and add this code:

Dim P As Printer
 For Each P In Printers
 List1.AddItem P.DeviceName
Next

'after that, the user cans select one of them, then:

Private Sub List1_Click()
 Dim P As Printer
 For Each P In Printers
   If P.DeviceName = List1.Text Then
      Set Printer = P
      Exit For
   End If
 Next

 'now selected printer is the default printer
 Printer.Print "MY TEXT"
 Printer.EndDoc
End Sub
0
 

Expert Comment

by:Mike Johnson
ID: 14812510
what is the "Printer" object... how do i reference it?
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now