audit logs

Mattlake

Board Regular
Joined
Apr 9, 2020
Messages
91
Office Version
  1. 2021
Platform
  1. Windows
Hi

This is just a question. Is there an access log that is stored somewhere on excel? to show who and when people open a file?

I seem to think there used to be but with my memory I may have imagined it.

Thank you
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
I have found the below VBA

VBA Code:
Option Explicit

Private Sub Workbook_Open()
Open ThisWorkbook.Path & "\log\event_usage.log" For Append As #1
Print #1, Application.UserName, Now
Close #1
End Sub

which does seem to work, any comments would be appreciated

Regards

Matthew
 
Upvote 0
Hi sorry about all these posts.

I have created (with a lot of youtube help :) )

VBA Code:
Private Sub workbook_beforesave(ByVal SaveAsUI As Boolean, cancel As Boolean)

Dim wbLog As Worksheet
Dim iLastRow As Integer

Set wbLog = Sheets("Log")
iLastRow = wbLog.Cells(wbLog.Rows.Count, "A").End(xlUp).Row + 1

wbLog.Cells(iLastRow, 1).Value = Environ("username")
wbLog.Cells(iLastRow, 2).Value = Now

End Sub

I would like to record which cells are changed as well. is this possible?

the excel workbook has 3 tabs 21-22 , 22-23 and log, I am not sure if it can only record from tabs not called log

does this make sense?

Regards

Matthew
 
Upvote 0
sorry for this,

I have tried to join 2 scripts together as below
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

Dim wbLog As Worksheet
Dim iLastRow As Integer

Set wbLog = Sheets("Log")
iLastRow = wbLog.Cells(wbLog.Rows.Count, "C").End(xlUp).Row + 1


wbLog.Cells(iLastRow, 1).Value = Target.Address

End With

Private Sub workbook_beforesave(ByVal SaveAsUI As Boolean, cancel As Boolean)

Dim wbLog As Worksheet
Dim iLastRow As Integer

Set wbLog = Sheets("Log")
iLastRow = wbLog.Cells(wbLog.Rows.Count, "A").End(xlUp).Row + 1

wbLog.Cells(iLastRow, 1).Value = Environ("username")
wbLog.Cells(iLastRow, 2).Value = Now

End Sub

it will log the name and the date when changed not the cell(s) changed

I assume I have either joined the incorrectly or the 1st section doesn't work.

any suggestions on how I have mucked up and if it can be sorted would be so helpful otherwise does anyone want a smashed PC?

I promise this will be the last time I ask for assistance this week.

Regards

Matthew
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,226
Members
452,620
Latest member
dsubash

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top