Djblois
07-12-2007, 01:27 PM
I recently updated the log file that my add-in uses. Originally, it updated the log file only when the program stopped running. Now it updates during each sub-procedure. Also, now I log all the variables I pass between Sub-procedures and fucntions. The only variables I have not been able to log are Ranges, Worksheets, and Workbooks. I have tried to cast them to as string but it still won't work. Here is the code for one of them that I tried:
Function FinalRow(ByVal shtToCount As Worksheet) As Long
errUpdateLogFile "Function-FinalRow", FinalRow
errUpdateLogFile "shtToCount", shtToCount
End Function
Sub errUpdateLogFile(ByVal stgSetting As String, Optional ByVal stgSetting2 As String)
'Create Log
If stgSetting2 = "" Then
Write #FileNumber, stgSetting
Else
Write #FileNumber, stgSetting & " " & stgSetting2
End If
End Sub
Also, I forgot I have tried to do it for Array's as well:
Sub errUpdateLogFileforArray(ByVal stgSetting As String, ByVal aSetting As Variant)
Dim logFileLine As Long
'Create Log
For logFileLine = LBound(aSetting, 1) To UBound(aSetting, 1)
Write #FileNumber, stgSetting & " " & aSetting(logFileLine, 0) & "#" & _
aSetting(logFileLine, 1)
Next logFileLine
End Sub
Function FinalRow(ByVal shtToCount As Worksheet) As Long
errUpdateLogFile "Function-FinalRow", FinalRow
errUpdateLogFile "shtToCount", shtToCount
End Function
Sub errUpdateLogFile(ByVal stgSetting As String, Optional ByVal stgSetting2 As String)
'Create Log
If stgSetting2 = "" Then
Write #FileNumber, stgSetting
Else
Write #FileNumber, stgSetting & " " & stgSetting2
End If
End Sub
Also, I forgot I have tried to do it for Array's as well:
Sub errUpdateLogFileforArray(ByVal stgSetting As String, ByVal aSetting As Variant)
Dim logFileLine As Long
'Create Log
For logFileLine = LBound(aSetting, 1) To UBound(aSetting, 1)
Write #FileNumber, stgSetting & " " & aSetting(logFileLine, 0) & "#" & _
aSetting(logFileLine, 1)
Next logFileLine
End Sub