Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 151
Default active Printer

Hi

Does anyone know how to return the number of pending jobs in the active
printer?

Many thanks in advance.
Libby

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default active Printer


"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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 151
Default active Printer

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 415
Default active Printer

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting the active printer Boog Excel Programming 0 June 5th 06 04:10 AM
Setting the active printer Boog Excel Programming 3 May 24th 06 01:48 AM
active printer Gixxer_J_97[_2_] Excel Programming 2 June 29th 05 02:24 PM
Active Printer Application Larry Excel Programming 1 December 15th 04 06:29 PM
Active printer Marijan Glavac Excel Programming 1 September 29th 04 01:41 PM


All times are GMT +1. The time now is 06:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"