Howdy, Stranger!

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


Get Printer Status after PDF file is printed

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.