Re: VBA and API



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


.



Relevant Pages

  • 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: unknown background process/inteference
    ... firstly thanks again and secondly plaease tell me how to use rkdetect. ... "Karl Levinson, ... > If a windows root kit is installed, what Windows is telling you cannot be ... >> adaware latest version with full updates ...
    (microsoft.public.security)
  • Re: ** READ THIS BEFORE POSTING - answers to frequently asked questions 2003.08.08
    ... > Karl are you the discussion police - no one has time to go ... >> I want to post a problem or question to the newsgroup. ... >> I just heard about a new Microsoft security patch update. ... >> I want to use the IPSec filtering or IP filtering feature of Windows ...
    (microsoft.public.security)
  • Re: Windows Startfehler
    ... Monitor kurz schwarz, es erscheint der Hinweis "No Signal" und dann ... > Karl Richter wrote: ... dass man beim Einbau einer neuen Graka Windows neuinstallieren sollte. ... Bevor ich auf den Vorschlag von Medion eingehe, ...
    (microsoft.public.de.german.windowsxp.sonstiges)
  • Re: Windows Startfehler
    ... Monitor kurz schwarz, es erscheint der Hinweis "No Signal" und dann ... > Karl Richter wrote: ... dass man beim Einbau einer neuen Graka Windows neuinstallieren sollte. ... Bevor ich auf den Vorschlag von Medion eingehe, ...
    (microsoft.public.de.german.windowsxp.sonstiges)

Loading