Private Function LogError()
Dim fso As New FileSystemObject Set fso = CreateObject("Scripting.FileSystemObject") If fso.FolderExists(GetSetting("ESS", "Settings", _ "GetErrorDir") & "\" & Format(Date, "yyyymmdd")) Then Else fso.CreateFolder (GetSetting("ESS", "Settings", _ "GetErrorDir") & "\" & Format(Date, "yyyymmdd")) End If If fso.FileExists(GetSetting("ESS", "Settings", _ "GetErrorDir", "c:\") & "\" & Format(Date, "yyyymmdd") _ & "\" & "ESSErrLog.txt") Then Open GetSetting("ESS", "Settings", "GetErrorDir", _ "c:\") & "\" & Format(Date, "yyyymmdd") & _ "\" & "ESSErrLog.txt" For Append As #1 Else fso.CreateTextFile (GetSetting("ESS", "Settings", _ "GetErrorDir", "c:\") & "\" & Format(Date, "yyyymmdd") _ & "\" & "ESSErrLog.txt") Open GetSetting("ESS", "Settings", "GetErrorDir", _ "c:\") & "\" & Format(Date, "yyyymmdd") & _ "\" & "ESSErrLog.txt" For Append As #1 End If DoEvents Write #1, Now & ":; FileName:" & FileName & "; Err#:" & _ Err.Number & "; " & Err.Source & "; Err.Desc:" & _ Err.Description; "" Close #1 Err.Clear ' Clear Error End Function Assumes: Getsettings is a VB function for getting settings from a desired location in the registry. In my registry I have created location references for moving the file and creating error logs. Side Effects: Current setup requires registry entries..If you are not familiar with creating and retrieving registry entries.. be careful. |