Re: VBA and API
- From: "Karl E. Peterson" <karl@xxxxxxxx>
- Date: Tue, 23 Aug 2005 12:18:47 -0700
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
.
- Follow-Ups:
- Re: VBA and API
- From: DS
- Re: VBA and API
- From: DS
- Re: VBA and API
- References:
- VBA and API
- From: DS
- Re: VBA and API
- From: Karl E. Peterson
- Re: VBA and API
- From: DS
- VBA and API
- Prev by Date: datepicker form in excel vba
- Next by Date: Re: VBA and API
- Previous by thread: Re: VBA and API
- Next by thread: Re: VBA and API
- Index(es):
Relevant Pages
|