Sub LogErrorText()
Dim intFile As Integer
'Store a free file handle into a variable
intFile = FreeFile
'Open a file named ErrorLog.txt in the current directory
'using the file handle obtained above
Open CurDir & "\ErrorLog.Txt" For Append Shared As intFile
'Write the error information to the file
Write #intFile, "LogErrorDemo", Now, Err, Error, CurrentUser()
'Close the file
Close intFile
End Sub
|