log of when files opened...

A

AmyTaylor

Hi all, i have used the following procedure to log when a specific file
has been opened, at present it sits in the ThisWorkbook object and
whenever the specific file is opened it writes the user, open date and
time and closed time and minutes open to a log.xls file.

BUT, i know want to roll this out across 40+ sheets, all of which can
be opened by selecting from a list and clicking to open.
I dont particularly want to have to copy this code into every workbook
in the directory, is there a way to set this running which will report
on the worksheet opened ??
Hope this explains things, if not let me know !
Thanks Amy xx
ps: vba below....:)

Private TimeOpen As Date

Private Sub Workbook_Open()
TimeOpen = Now
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim TimeClosed As Date
TimeClosed = Now
Open "s:\reportst\users\Log.xls" For Append As #1
Dim sPath As String
Print #1, ThisWorkbook.Path, Application.UserName, TimeOpen,
TimeClosed, Format((TimeOpen - TimeClosed), "hh:nn:ss")
Close #1

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top