Code:
Option Explicit
Function pruefe_Pfad(strPath As String)
Dim fso As Object
Dim strText As String
Set fso = CreateObject("Scripting.FileSystemObject")
Dim oFile As Object
If fso.FileExists(strPath) Then 'wenn Datei vorhanden, mach weiter
Else 'sonst
Set oFile = fso.CreateTextFile(strPath) 'erstelle Datei
End If
Set fso = Nothing
Set oFile = Nothing
End Function
'__________________________________________________________________________________________________________
'__________________________________________________________________________________________________________
Sub Schreibe_Log(PathName As String)
Dim strDatei$, Sep$, Zeile As Long, strText
Dim Timestamp As String
Dim user As String
Dim DATAPath As String
DATAPath = "PfadzumLogfile\gewünschterLogfilename.txt"
pruefe_Pfad DATAPath
Timestamp = Format(Now, "mm-dd-yyyy_HH-mm-ss") 'Zeitstempel
user = Environ("Username") 'ausführender User
strDatei = DATAPath
Sep = ";"
Open strDatei For Append As #1
strText = Timestamp & " : ausgeführt von: " & user & " Pfad: " & PathName
Print #1, strText
Close #1
End Sub