Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Get Printer Status after PDF file is printed

Anita GundalaAnita Gundala Posts: 20Member
I am writing a windows application to send pdf files to printer, one at time, after file is printed I want to get the status from printer as "Printed".

so far I have the code (working) which can send the selected pdf to printer.
Now I am trying to use this following code to get the status of printer, after the file is printed. but, not working.

objCollection value is being "printer property evaluation failed"

Please help me if anyone knows how to do it.

Imports System.Management 'used namespace

Private objOS As ManagementObjectSearcher
Private objCollection As ManagementObjectCollection
Private objMgmt As ManagementObject

Dim jobName As String
Dim documentName As String
Dim PrinterStatus As String
Dim PrinterStatus1 As String

Dim searchQuery As String
Dim objMgmt As ManagementObject
searchQuery = "SELECT * FROM Win32_PrintJob"
objOS = New ManagementObjectSearcher(searchQuery)
objCollection = objOS.Get()

For Each objMgmt In objCollection
jobName = objMgmt.Properties("Name").Value.ToString()
documentName = objMgmt.Properties("Document").Value.ToString()
PrinterStatus = objMgmt.Properties("Status").Value.ToString()
PrinterStatus1 = objMgmt.Properties("StatusMask").Value.ToString()
If PrinterStatus1 = "128" Then '128 means Printed
Change_Status()'write the status to database as printed
MsgBox("objMgmt: " + documentName + "Status: " + PrinterStatus1, vbExclamation)
End If

Catch ex As Exception
End Try

Thanks in advance!
Sign In or Register to comment.