AW: =Environ("USERNAME") - o.T.
21.06.2004 09:21:41
Andy
Hiermit lasse ich den Anmeldenamen Protokollieren:
'Ermitteln des Windows-Anmelde-Namens
Private Declare
Function GetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) _
As Long
Function UserName()
Dim sName As String
Dim nSize As Long
Dim lngResult As Long
nSize = 100
sName = Space$(100)
lngResult = GetUserName(sName, nSize)
If lngResult <> 0 Then
UserName = Left$(sName, nSize - 1)
End If
End Function
Sub Zugriff()
'Zugriffsprotokoll
Dim tarWKs As Worksheet
Dim lastR As Integer, i As Integer
Set tarWKs = Worksheets("Zugriffsprotokoll")
Debug.Print tarWKs.Name
lastR = tarWKs.Cells(65536, 2).End(xlUp).Row + 1
Debug.Print lastR
tarWKs.Unprotect Password:=""
'Alte Daten löschen
With tarWKs
For i = lastR To 2 Step -1
Debug.Print .Cells(i, 2)
If Format(.Cells(i, 2), "dd.mm.yyyy") < Format(Now - 7, "dd.mm.yyyy") Then
.Rows(i).Delete Shift:=xlUp
End If
Next i
End With
lastR = tarWKs.Cells(65536, 2).End(xlUp).Row + 1
tarWKs.Cells(lastR, 2).Value = Now
tarWKs.Cells(lastR, 3).Value = Usermodul.UserName 'Windows-Anmeldung
ActiveSheet.Protect Password:=""
End Sub
Gruß
Andy