Solved

Set a printer as the default printer

Posted on 2001-06-13
3
226 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

770 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