Amazing!!! I'm really impressed! Thank you so much! I will just have the
log file saved to my network drive so I can access it from my computer and do
"check ups" on my program!!
"RB Smissaert" wrote:
See if something like this suits you:
Sub test()
Dim bt As Byte
Dim btSum As Byte
Dim arrErrorData(1 To 6)
10 On Error GoTo ERROROUT
20 For bt = 1 To 300
30 btSum = btSum + bt
40 Next
50 Exit Sub
ERROROUT:
60 arrErrorData(1) = Format(Now, "dd/mmm/yyyy hh:mm")
70 arrErrorData(2) = "Module: Module1"
80 arrErrorData(3) = "Procedu Sub test()"
90 arrErrorData(4) = "Error line: " & Erl
100 arrErrorData(5) = "Error number: " & Err.Number
110 arrErrorData(6) = Err.Description
120 Save1DArrayToTextAppend "C:\ErrorqqLog.txt", arrErrorData
End Sub
Sub Save1DArrayToTextAppend(txtFile As String, _
arr As Variant, _
Optional LB As Long = -1, _
Optional UB As Long = -1)
Dim r As Long
Dim hFile As Long
If LB = -1 Then
LB = LBound(arr)
End If
If UB = -1 Then
UB = UBound(arr)
End If
hFile = FreeFile
Open txtFile For Append As hFile
For r = LB To UB
If r = UB Then
Write #hFile, arr(r)
Else
Write #hFile, arr(r);
End If
Next
Close #hFile
End Sub
Just copy and paste in a module and run the Sub test.
RBS
"Bob the Kart Racing fool"
wrote in message ...
How would I create an error log that would store log data to a cell range
or
a .txt file, to include: Error number, error name/description, line of
suspected erronious code and if possible some basic information about what
they did to create that error?
I am having some intermittent errors that occur in my VB code on different
machines... Because no one else at my office has any idea what I'm doing
they disregard the error and move on. Then all I get is the extremely
useful
error report from them: "Your excel file doesn't work!" which is very hard
to
debug!
Any help or suggestions on implementing this would be appreciated.
Thank you!
~Josh