PC Review


Reply
Thread Tools Rate Thread

active Printer

 
 
=?Utf-8?B?TGliYnk=?=
Guest
Posts: n/a
 
      18th Jun 2007
Hi

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

Many thanks in advance.
Libby

 
Reply With Quote
 
 
 
 
=?Utf-8?B?dXJrZWM=?=
Guest
Posts: n/a
 
      18th Jun 2007

"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
 
Reply With Quote
 
NickHK
Guest
Posts: n/a
 
      19th Jun 2007
This will tell you pretty much everything about your printer(s)/queue:
http://vb.mvps.org/samples/project.asp?id=PrnInfo

NickHK

"Libby" <(E-Mail Removed)> ¼¶¼g©ó¶l¥ó·s»D:FC128164-AB16-4D25-A5DE-(E-Mail Removed)...
> Hi
>
> Does anyone know how to return the number of pending jobs in the active
> printer?
>
> Many thanks in advance.
> Libby
>



 
Reply With Quote
 
=?Utf-8?B?TGliYnk=?=
Guest
Posts: n/a
 
      21st Jun 2007
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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Printer and active directory Yita Windows Vista Print / Fax / Scan 1 31st May 2008 10:42 PM
Setting Active Printer Rebecca Microsoft Word New Users 2 20th Dec 2005 09:33 PM
active printer =?Utf-8?B?R2l4eGVyX0pfOTc=?= Microsoft Excel Programming 2 29th Jun 2005 02:24 PM
Active X OPOS Printer DS Microsoft Access Form Coding 0 27th Nov 2004 10:42 PM
Active printer Marijan Glavac Microsoft Excel Programming 1 29th Sep 2004 01:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:47 PM.