Re: VBA and API



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.
Say your article in Visual Studio Magazine,,,it shows paused unavailable, all kinds of different status, but when I run your example I only get ready?
Thanks
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 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
    ... 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: 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. ...
    (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)

Loading