Hello,
I have this code that records all changes made in a workbook (audit trail). The thing is that it records everything even if the workbook is not saved. How can I change this in order to do the recording only when it is save.
'Sub AuditTrail(ByVal Sh As Object, ByVal Target As Range)
'Dim strFileName As String
'strFileName = "c:test.txt"
' Open strFileName For Append As #1
' If Target.Count > 1 Then
Print #1, ThisWorkbook.Name & vbTab & Sh.Name & vbTab & Target.Address & vbTab & Environ("username") & vbTab & Date & vbTab & Time & vbTab & "Multiple cells changed"
Else
' Print #1, ThisWorkbook.Name & vbTab & Sh.Name & vbTab & Target.Address & vbTab & Environ("username") & vbTab & Date & vbTab & Time & vbTab & Target.Value
' End If
' Close #1
'End Sub
I have this code that records all changes made in a workbook (audit trail). The thing is that it records everything even if the workbook is not saved. How can I change this in order to do the recording only when it is save.
'Sub AuditTrail(ByVal Sh As Object, ByVal Target As Range)
'Dim strFileName As String
'strFileName = "c:test.txt"
' Open strFileName For Append As #1
' If Target.Count > 1 Then
Print #1, ThisWorkbook.Name & vbTab & Sh.Name & vbTab & Target.Address & vbTab & Environ("username") & vbTab & Date & vbTab & Time & vbTab & "Multiple cells changed"
Else
' Print #1, ThisWorkbook.Name & vbTab & Sh.Name & vbTab & Target.Address & vbTab & Environ("username") & vbTab & Date & vbTab & Time & vbTab & Target.Value
' End If
' Close #1
'End Sub