Re: VBA and API



Karl E. Peterson wrote:

DS wrote:

Karl E. Peterson wrote:

DS wrote:


Karl E. Peterson wrote:


Not sure if this is the right place, let me know if its not.  I
recently downloaded code from Jonathan West that kicks back the
staus of your printer before you print.  The problem is it returns
the status of whats in the Print Que, "this works fine",  not
whats connected to the computer either locally or accross the
network.  I need to find if the printer is able to print a report
and if it's not, because it lacks paper or is offline, then send
it to another printer.  Is there a way to do this?  I'm using
Access 2002.

I believe the only place Windows exposes this information is through the print queue.

OH Boy, how can I do this? I've seen other applications send up an Error Box whenver a printer is offline, how is this done? Without even sending a print job. Also is there a way to monitor the print spooler, and send a message from there?


You can get the status of any given printer pretty easily.  Didn't
mean to confuse things by using the term "pring queue."  All the
same group of stuff.  IOW, what you see in the queue is the same
info that's available to you.

What you'll need to do is call GetPrinter, and check the Status
member (of the PRINTER_INFORMATION_2 structure that's returned) for
the PRINTER_STATUS_OFFLINE flag. It's not a pretty API to call, but
that's what Windows (NT) offers.  There's a functional example that
shows this (in CPrinterInfo.cls), and a *lot* more, at
http://vb.mvps.org/samples/PrnInfo.  I've never used that class in
VBA, but I'm told it drops right in.

Earlier versions of Windows, 9x and 3.x, allowed direct port I/O.  I
wonder if that's what you're remembering?  Directly probing a
printer port, you could tell whether an attached printer was on or
offline.  Those are days gone by, however.

Thanks Karl, I downloaded the example started it up, I saw my printers. So I popped the lid on one of them and tried to print to it, it said ready, so I went to the Que and that said printing....I waited nothing happened. So where is this functional example of CPrinterInfo.cls ? Thank you for your help.


That sample fairly well (in my experience) replicates what Windows shows.  Are you
seeing the same thing as you do if you Open Printers?  In general, I find the status
info to be woefully lacking, and often not updated until you actually try to print.
Ok I see what you mean, it says printing, just like in windows. But status is ready when I take it offline.
DS
.




Relevant Pages

  • Re: VBA and API
    ... The problem is it returns the status of whats in the Print Que, "this works fine", not whats connected to the computer either locally or accross the network. ... I need to find if the printer is able to print a report and if it's not, because it lacks paper or is offline, then send it to another printer. ... through the print queue. ... That sample fairly well replicates what Windows shows. ...
    (microsoft.public.office.developer.vba)
  • Re: VBA and API
    ... >> the print queue. ... > Error Box whenver a printer is offline, ... It's not a pretty API to call, but that's what Windows offers. ... Earlier versions of Windows, 9x and 3.x, allowed direct port I/O. ...
    (microsoft.public.office.developer.vba)
  • Re: VBA and API
    ... recently downloaded code from Jonathan West that kicks back the staus of your printer before you print. ... The problem is it returns the status of whats in the Print Que, "this works fine", not whats connected to the computer either locally or accross the network. ... I need to find if the printer is able to print a report and if it's not, because it lacks paper or is offline, then send it to another printer. ... the print queue. ...
    (microsoft.public.office.developer.vba)
  • Re: Sending a document to print causes the Windows 2003 print queue of that printer to go offline
    ... Windows 2003 print queue/printer of that printer to go offline. ... queue remains offline until the printer is power cycled. ...
    (microsoft.public.win2000.printing)
  • Sending a document to print causes the Windows 2003 print queue of that printer to go offline
    ... Windows 2003 print queue/printer of that printer to go offline. ... queue remains offline until the printer is power cycled. ...
    (microsoft.public.win2000.printing)