General

6.172 WMI - Printer JOB (Informazioni processi di Stampa)
  Alessandro Baraldi
Il codice VBA che segue mostra come recuperare lo stato dei JOBS della stampante attraverso la Classe Win32_PrintJob di WMI.
Maggiori informazioni sull'argomento possono essere lette al link:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_printjob.asp
Private Type prtJob
   mCaption As String
   mDataType As String
   mDescription As String
   mDocument As String
   mDriverName As String
   mElapsedTime As Date
   mHostPrintQueue As String
   mInstallDate As Date
   mJobId As Long
   mJobStatus As String
   mName As String
   mNotify As String
   mOwner As String
   mPagesPrinted As Long
   mParameters As String
   mPrintProcessor As String
   mPriority As Long
   mSize As Long
   mStartTime As Date
   mStatus As String
   mStatusMask As Long
   mTimeSubmitted As Date
   mTotalPages As Long
   mUntilTime As Date
End Type

Public p() As prtJob

Public Function retPrinterJob(ByRef prt() As prtJob)
   Dim nIndex As Long
   Dim PrintJobSet As Object
   Dim printjob As Object
   Set PrintJobSet = GetObject("winmgmts:").InstancesOf("Win32_PrintJob")
   
   If (PrintJobSet.Count = 0) Then MsgBox "No print jobs!"
   ReDim prt(PrintJobSet.Count)
   For Each printjob In PrintJobSet
      With prt(nIndex)
         .mName = printjob.Name
         .mJobId = printjob.JobId
         .mStatus = printjob.Status
         .mStatus = printjob.TotalPages
         .mPagesPrinted = printjob.PagesPrinted
         .mDocument = printjob.Document
         .mNotify = printjob.Notify
         .mElapsedTime = printjob.elapsedtime
         .mHostPrintQueue = printjob.HostPrintQueue
         .mSize = printjob.size
         Debug.Print .mName & vbCrLf & _
                     .mJobId & vbCrLf & _
                     .mStatus & vbCrLf & _
                     .mStatus & vbCrLf & _
                     .mPagesPrinted & vbCrLf & _
                     .mDocument & vbCrLf & _
                     .mNotify & vbCrLf & _
                     .mElapsedTime & vbCrLf & _
                     .mHostPrintQueue & vbCrLf & _
                     .mSize
         '//   Ecc......!
      End With
      nIndex = nIndex + 1
   Next
   Set PrintJobSet=Nothing
   set printjob=Nothing
End Function


Se pensate di avere del materiale freeware interessante e volete pubblicarlo, allora leggete qui.