Re: VBA and API



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.
--
Working Without a .NET?
http://classicvb.org/petition


.



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
    ... >>> Error Box whenver a printer is offline, ... >> Earlier versions of Windows, 9x and 3.x, allowed direct port I/O. ... > Thanks Karl, I downloaded the example started it up, I saw my ...
    (microsoft.public.office.developer.vba)
  • 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)
  • 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)