Report Sent to Printer? (1 Viewer)

sonic8

AWF VIP
Local time
Today, 13:32
Joined
Oct 27, 2015
Messages
1,372
I want to know when a certain report is sent to a printer (as opposed to being displayed as preview). I.e., I want to be able to distinguish preview and printing in any of the reports Print events.

This must also work if the report is displayed in preview before being sent to the printer and also when the report is displayed in preview as a dialog.

I’ve spent several hours researching this matter. I’ve “found” more ways that do not work than I can list here.

Please note:
1.) It is not feasible in this scenario to intercept each and every command to print a report. (I doubt this is reliably feasible in any scenario, but definitely not here.)
2.) Please do not insult me by posting unverified AI garbage as suggestion.
 
If you have enabled printer logging, you can view after-the-fact that a file was sent to a networked printer via the print queue manager. That fact would be in a system event log. However, the question of print verification has come up before and I don't recall that we had a foolproof answer.

For example, the log might show that printing was started, but once the job is sent to a networked printer, it is no longer active on your PC. You have no way of knowing if the printer actually finished the job unless that printer allows interactions with its contributor print-job sources. If someone cancels the job, you have little to no way of seeing that. If your printer is hard-wired to the computer (rare these days with the advent of networked autonomous printers), you MIGHT be able to find a program to monitor activity of that device.

Part of the problem is that by default, any printer's queue is managed by a system task (Print Queue Manager, probably running under a SVCHOST job) and you are not allowed to interact with an independent task unless you set up interaction conditions... such as logging. I would be curious to find if there is a foolproof way to find out what you asked. I will not say "impossible" but I will say "I'm skeptical."

I think the problem is less that the data doesn't exist and more that you can't get to the data that DOES exist.
 
Part of the problem is that by default, any printer's queue is managed by a system task (Print Queue Manager, probably running under a SVCHOST job) and you are not allowed to interact with an independent task unless you set up interaction conditions... such as logging. I would be curious to find if there is a foolproof way to find out what you asked. I will not say "impossible" but I will say "I'm skeptical."
@The_Doc_Man, this is a very good idea and one I consider for further investigation.
I think, some of the stated reasons for your skepticism are not that big of a deal. There is a set of Windows API functions for interacting with printer spoolers. However, the apparently most suitable functions for monitoring the printer spooler depend on Windows event signalling (e.g. WaitForSingleObject), which work by blocking a thread until an event of interest occurs. This is difficult to implement in a single threaded environment such as VBA.

I probably will investigate the above mentioned API in more depth but I still hope for a simpler solution which I overlooked so far.
 
A simpler solution would be to ask the user "Did it print OK y/n", but I presume you have already ruled that out.

Did you also rule out offering 2 buttons, one for preview and one for print? You would still have to deal with Ctrl+P after preview, but that would be the only keystroke to catch. EDIT: perhaps better: if there are new Detail_Print events after the initial set, that indicates print after preview.

I tried a variety of events and properties, but nothing so far. I will ask a friend and reports guru if he has any ideas.
 
which work by blocking a thread until an event of interest occurs. This is difficult to implement in a single threaded environment such as VBA.

True enough. Single-threaded VBA makes parallel action difficult to track. But more conditions than just "events of interest" are involved, I think.

You are correct that an API can talk to a spooler task running on the same machine. However, the next question is whether your printer is networked autonomously (smart printer) or networked as a dumb device on another machine? If so, you would lose potentially contact with any print job to a remote printer unless that remote printer allows status queries.

The problem boils down to the fact that we have progressed to "set it and forget it" devices to make our offices simpler and more efficient. So much so that if you ask a printer, "Did you print job 123XYZ?" it might reply "I forgot."
 
@BlueSpruce - the question is, if the NET USE LPTn targets a busy printer, does the print job automatically get spooled anyway, thus falling out of your span of control? A LOT of Windows commands that can't be executed instantly can sometimes get queued up. This auto-queue-print-job option has been part of PCs since MS-DOS was a thing.
 
@BlueSpruce - the question is, if the NET USE LPTn targets a busy printer, does the print job automatically get spooled anyway, thus falling out of your span of control?
No, it doesn't get spooled. The print job fails and you get a printer busy message which you would have to trap in your error handler.
A LOT of Windows commands that can't be executed instantly can sometimes get queued up. This auto-queue-print-job option has been part of PCs since MS-DOS was a thing.
Same with Unix, VAX/VMS, and other platforms. I have an Access app that prints directly to a parallel Okidata dot matrix printer using PRINT#1 statements in my VBA code and selecting the net printer's IP address.
 
IMG_0300.jpeg
 

Users who are viewing this thread

Back
Top Bottom