الاخ الكريم "منير" جزاك الله خيرا وفقك الله
اخي الكريم انسخ هذا الكود في thisworkbook
Option Explicit
Private Sub Workbook_Open()
LogInformation "Opened by " & Application.UserName & _
" " & Format(Now, "dd mmm yyyy hh:mm:ss")
End Sub
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
LogInformation ActiveSheet.Name & Selection.Address & " Changed: " & _
" " & Format(Now, "dd mmm yyyy hh:mm:ss")
End Sub
Private Sub Workbook_BeforePrint(Cancel As Boolean)
LogInformation ActiveSheet.Name & "Printed: " & _
" " & Format(Now, "dd mmm yyyy hh:mm:ss")
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
LogInformation "Saved by " & Application.UserName & _
" " & Format(Now, "dd mmm yyyy hh:mm:ss")
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
LogInformation "Closed by " & Application.UserName & _
" " & Format(Now, "dd mmm yyyy hh:mm:ss")
End Sub
وانسخ هذا الكود في module
Option Explicit
Public Function LogInformation(LogMessage$)
On Error GoTo MakeFolder
Entry:
Open "c:\MyLogFiles\" & Left(ThisWorkbook.Name, _
Len(ThisWorkbook.Name) - 4) & _
" Log.Log" For Append As #1
Print #1, LogMessage
Close #1
Exit Function
MakeFolder:
MkDir "c:\MyLogFiles"
Resume Entry
End Function