Ardus - This is fantastic. Just what I was looking for. Thank you so
much. One followup question, I tried to modify your code to to create
log entries for close events and save events, but was unable to
understand how the code is called.
Under CAppEvents I modified it to:
Option Explicit
Public WithEvents oApp As Application
Private Sub Class_Initialize()
Set oApp = Application
End Sub
Private Sub oApp_WorkbookOpen(ByVal Wb As Workbook)
Dim rCell As Range
With ThisWorkbook.Worksheets("Log").Cells(Rows.Count,
"A").End(xlUp).Offset(1, 0)
.Value = Now
.Offset(0, 1) = Wb.Path
.Offset(0, 2) = Wb.Name
.Offset(0, 3) = "open"
End With
End Sub
Private Sub oApp_WorkbookClose(ByVal Wb As Workbook)
Dim rCell As Range
With ThisWorkbook.Worksheets("Log").Cells(Rows.Count,
"A").End(xlUp).Offset(1, 0)
.Value = Now
.Offset(0, 1) = Wb.Path
.Offset(0, 2) = Wb.Name
.Offset(0, 3) = "close"
End With
End Sub
Private Sub oApp_WorkbookSave(ByVal Wb As Workbook)
Dim rCell As Range
With ThisWorkbook.Worksheets("Log").Cells(Rows.Count,
"A").End(xlUp).Offset(1, 0)
.Value = Now
.Offset(0, 1) = Wb.Path
.Offset(0, 2) = Wb.Name
.Offset(0, 3) = "Save"
End With
End Sub
and under This Workbook I modified to:
Option Explicit
Dim oAppEvents As CAppEvents
Private Sub Workbook_Open()
Set oAppEvents = New CAppEvents
End Sub
Private Sub Workbook_Close()
Set oAppEvents = New CAppEvents
End Sub
Private Sub Workbook_Save()
Set oAppEvents = New CAppEvents
End Sub
Any idea what tweak would be needed to also log saves and closes?
Thank you.
This is so fantastic.
Jgalt
Ardus Petus wrote:
Here is an example of what you need: http://cjoint.com/?ghl6Ew682v
HTH
--
AP
a écrit dans le message de news:
...
I'm looking for a program or process by which all excel files will be
written to a text log file or a personal.xls worksheet on my pc.
A log entry would be created each time I open a file.
The log entry would list the name of the file, the path, the date, and
time, and the file type.
Any ideas would be much appreciated.
Thanks,
JGalt