1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| Public Save_log As Boolean
Public Wb As Workbook
Private Sub Workbook_Open()
Dim Wb As Workbook
Save_Log = False
Dim a As Long
Dim Fs As Object, F As Object
Set Fs = CreateObject("Scripting.FileSystemObject")
Set F = Fs.GetFile(ActiveWorkbook.FullName)
a = F.Attributes
If F.Attributes = 32 Then
Application.ScreenUpdating = False 'Masquer l'affichage
Set Wb = Workbooks.Open(Filename:="\\TB\test\Service\Divers\LOG\CE")
a = Wb.Sheets("Trace").Range("A65536").End(xlUp).Row + 1
Wb.Sheets("Trace").Range("A" & a).Value = Application.UserName
Wb.Sheets("Trace").Range("B" & a).Value = VBA.Date
Wb.Sheets("Trace").Range("C" & a).Value = Now - Int(Now)
Wb.Close True
Application.ScreenUpdating = True
End If
End Sub
Private Sub Workbook_close()
Wb.Close Save_Log
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If SaveAsUI Then Cancel = True
End Sub |