L
Ludo
Guest
Re bonjour
Autre problème avec une macro compatible sur XP et qui fonctionne de temps en temps sur 97.
Private Declare Function GetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Sub Workbook_BeforeClose(Cancel As Boolean) ' log fermeture
LogUserAction "Closed"
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) 'Log de sauvegarde
LogUserAction "Saved"
End Sub
Private Sub Workbook_BeforeOpen() 'log ouverture
LogUserAction "Opened"
End Sub
Function UserName() 'Log user
Dim S As String, n As Long, Res As Long
S = String(200, 0): n = 199: Res = GetUserName(S, n)
UserName = UCase(Left(S, n - 1))
End Function
Sub LogUserAction(Action As String) 'création du fichier log "nom du classeur" dans le répertoire du classeur
Dim f As Integer, HistLog As String
HistLog = Left(ThisWorkbook.Name, InStr(ThisWorkbook.Name, ".") - 1)
HistLog = "\\GIL030SN\StatEComm\Planning_E-Commerce\bdd_planning\backup\log\" & HistLog & ".txt"
f = FreeFile
Open HistLog For Append Shared As #f
Write #f, Format(Now, "yyyy-mm-dd hh:mm:ss"), UserName, Action
Close #f
End Sub
Quelqu'un aurait une idée adaptée à Excel 97
Merci
Ludo
Autre problème avec une macro compatible sur XP et qui fonctionne de temps en temps sur 97.
Private Declare Function GetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Sub Workbook_BeforeClose(Cancel As Boolean) ' log fermeture
LogUserAction "Closed"
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) 'Log de sauvegarde
LogUserAction "Saved"
End Sub
Private Sub Workbook_BeforeOpen() 'log ouverture
LogUserAction "Opened"
End Sub
Function UserName() 'Log user
Dim S As String, n As Long, Res As Long
S = String(200, 0): n = 199: Res = GetUserName(S, n)
UserName = UCase(Left(S, n - 1))
End Function
Sub LogUserAction(Action As String) 'création du fichier log "nom du classeur" dans le répertoire du classeur
Dim f As Integer, HistLog As String
HistLog = Left(ThisWorkbook.Name, InStr(ThisWorkbook.Name, ".") - 1)
HistLog = "\\GIL030SN\StatEComm\Planning_E-Commerce\bdd_planning\backup\log\" & HistLog & ".txt"
f = FreeFile
Open HistLog For Append Shared As #f
Write #f, Format(Now, "yyyy-mm-dd hh:mm:ss"), UserName, Action
Close #f
End Sub
Quelqu'un aurait une idée adaptée à Excel 97
Merci
Ludo