Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
Does anyone know how to return the number of pending jobs in the active printer? Many thanks in advance. Libby |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() "Libby" wrote: Hi Does anyone know how to return the number of pending jobs in the active printer? Many thanks in advance. Libby I used this to get print job count and some other data (Windows XP / Office 2007): Sub getPrintJobs() 'connect to local computer strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\cimv2") 'get all printers installed Set colInstalledPrinters = objWMIService.ExecQuery _ ("Select * from Win32_Printer") 'get the active printer name For Each objPrinter In colInstalledPrinters If InStr(ActivePrinter, objPrinter.Name) Then strPrinterName = objPrinter.Name End If Next If strPrinterName = "" Then MsgBox "Error getting the printer name" Exit Sub End If 'get pending jobs for the active printer Set colPrintJobs = objWMIService.ExecQuery _ ("Select * from Win32_PrintJob " & _ "where DriverName = '" & strPrinterName & "'") 'job count Debug.Print "Pending jobs " _ & "for " & strPrinterName _ & ": " & colPrintJobs.Count 'print job data For Each objPrintJob In colPrintJobs Debug.Print "Job name" & ": " _ & objPrintJob.Document _ & " , Total pages" & ": " & _ objPrintJob.TotalPages _ & " , Job status" & ": " _ & objPrintJob.Status Next End Sub Hope you can use it. -- urkec |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks, that worked well in Excel 2003, though Excel 2000 didn't seem to like
it "urkec" wrote: "Libby" wrote: Hi Does anyone know how to return the number of pending jobs in the active printer? Many thanks in advance. Libby I used this to get print job count and some other data (Windows XP / Office 2007): Sub getPrintJobs() 'connect to local computer strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\cimv2") 'get all printers installed Set colInstalledPrinters = objWMIService.ExecQuery _ ("Select * from Win32_Printer") 'get the active printer name For Each objPrinter In colInstalledPrinters If InStr(ActivePrinter, objPrinter.Name) Then strPrinterName = objPrinter.Name End If Next If strPrinterName = "" Then MsgBox "Error getting the printer name" Exit Sub End If 'get pending jobs for the active printer Set colPrintJobs = objWMIService.ExecQuery _ ("Select * from Win32_PrintJob " & _ "where DriverName = '" & strPrinterName & "'") 'job count Debug.Print "Pending jobs " _ & "for " & strPrinterName _ & ": " & colPrintJobs.Count 'print job data For Each objPrintJob In colPrintJobs Debug.Print "Job name" & ": " _ & objPrintJob.Document _ & " , Total pages" & ": " & _ objPrintJob.TotalPages _ & " , Job status" & ": " _ & objPrintJob.Status Next End Sub Hope you can use it. -- urkec |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This will tell you pretty much everything about your printer(s)/queue:
http://vb.mvps.org/samples/project.asp?id=PrnInfo NickHK "Libby" ... Hi Does anyone know how to return the number of pending jobs in the active printer? Many thanks in advance. Libby |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Setting the active printer | Excel Programming | |||
Setting the active printer | Excel Programming | |||
active printer | Excel Programming | |||
Active Printer Application | Excel Programming | |||
Active printer | Excel Programming |