Solved

Default Printer

Posted on 2004-04-23
4
263 Views
Last Modified: 2010-05-02
Hello,
  Can someone help me, I am trying to get the name of the current default printer, I am using VBA (Microsoft Access 2000).

I want to be able to display the current name of the default printer.  

Cheers everyone.

0
Comment
Question by:PhillipBarber
  • 2
4 Comments
 
LVL 14

Accepted Solution

by:
aelatik earned 125 total points
ID: 10899747
Wmi call would do it...

On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Printer", , 48)
For Each objItem In colItems
    If objItem.Attributes And 4 Then ' attr nr. 4 represents default printer
       MsgBox objItem.Name
    End If
Next
0
 
LVL 14

Expert Comment

by:aelatik
ID: 10899852
in VBA this also result the default printer...

MsgBox Application.ActivePrinter
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 10900497
msgbox printer.DeviceName
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…

932 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