• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1121
  • Last Modified:

Logging Windows Print events

I would like to know if it's possible to capture the fact that the contents of a OLE field was printed from the native application being used to view the OLE contents.

Example: A user opens a Word Document from an embedded or linked OLE field, prints that document, and then somewhere in the VBA code for that screen my MS Access app can see that something was just printed and ask the user to enter a few parameters to establish a log that a printed copy was made.

I could just ask every time the screen closed, "Did you pint it?"  Although that's going to get annoying very fast.

Is there anything happening in the bowels of Access or the operating system I could use as a reasonable trigger to ask the user to make a print log?
0
David Smithstein
Asked:
David Smithstein
  • 5
  • 2
1 Solution
 
Jeffrey CoachmanCommented:
If this can be done from the OS, it is beyond me.

About the best you may be able to do is log this if a user clicks a "Print" button.

It would add the various pieces of info to a table, ...something roughly like this:

Currentdb.execute "INSERT INTO YourTable (Field1, Field2, Field3,...)
VALUES (value1, value2, value3,...)",dbfailonerror

JeffCoachman
0
 
Jeffrey CoachmanCommented:
0
 
David SmithsteinCEOAuthor Commented:
Thanks, but that doesn't help me as i'm storing controlled documents, MS Word, .pdf. Excel, anything that is OLE enabled and would like to add a feature that helps the client know if any were printed so obsolete ones can be retrieved when needed.
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
David SmithsteinCEOAuthor Commented:
0
 
David SmithsteinCEOAuthor Commented:
Almost, but not quite. Is it possible to query the Operational log of the PrintService?  When I modify the code to look in that folder, I get "0 logs searched" even though I can go into event viewer and see a print job (EventID 307) there from yersterday.

Dim objObject As WbemScripting.SWbemObject
Dim setObjectSet As WbemScripting.SWbemObjectSet
Dim strServer As String
Dim strWQL As String
Dim svcServices As WbemScripting.SWbemServices
Dim varInsertionString As Variant
Dim Counter As Integer

Counter = 0
strServer = "."  ' This computer
Set svcServices = GetObject("winmgmts:\\" & strServer & "\root\cimv2")

strWQL = "SELECT * " & _
         "FROM Win32_NTLogEvent " & _
         "WHERE Logfile = ""Microsoft-Windows-PrintService/Operational"""
Set setObjectSet = svcServices.ExecQuery(strWQL)

For Each objObject In setObjectSet
   ' MsgBox "Category: " & objObject.Category
 If objObject.EventCode = "307" Then
    MsgBox "Found Print Job"
     MsgBox "Time Generated: " & objObject.TimeGenerated
    MsgBox "Time Written: " & objObject.TimeWritten
    Exit Sub
 End If
 Counter = Counter + 1
  '  MsgBox "CategoryString: " & objObject.CategoryString
  '  MsgBox "Computer Name: " & objObject.ComputerName
 '   MsgBox "Data: " & objObject.Data
 '   MsgBox "Event Code: " & objObject.EventCode
  '  MsgBox "Event Identifier: " & objObject.EventIdentifier
 '   For Each varInsertionString In objObject.InsertionStrings
 '       MsgBox "Insertion String: " & varInsertionString
 '   Next
 '   MsgBox "Logfile: " & objObject.Logfile
 '   MsgBox "Message: " & objObject.message
 '   MsgBox "Record Number: " & objObject.RecordNumber
 '   MsgBox "Source Name: " & objObject.SourceName
   
'    MsgBox "Type: " & objObject.Type
'    MsgBox "User: " & objObject.User

    Set objObject = Nothing
Next
Set setObjectSet = Nothing

Set svcServices = Nothing
MsgBox Counter & " logs searched"
0
 
mo_patelCommented:
to log all print events over a network look at event ID's

"System 10: " or "System 307: "

best way to use this is to look at SIEM software which you can use to correlate and automate it so each time an event occurs its correlated together
0
 
David SmithsteinCEOAuthor Commented:
I was told by a programmer of event log software in England that:

"I think the problem is that the log you're after isn't covered by the eventlog WMI provider, i.e. so far as I'm aware there is no way to get at that log via WMI. This is something that has caused me major headaches and really ticks me off about MS; it goes completely against the spirit of WMI.

There is however another way to get at that log - look up the "Windows Event Log API"


I'll I've been able to find is code on how to post a log to the event log, but nothing to simple read it, and hopefull limit the read based on a date range of just today.
0
 
David SmithsteinCEOAuthor Commented:
tested this code and I am able to read event logs on my Windows 7 computer using MS Access 2010
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now