Public Sub WriteFile(ByVal strFile As String, ByVal strText As String)
On Error GoTo ErrHandler
Dim fso As New FileSystemObject
Dim ts As TextStream
If Dir(strFile) = "" Then
Set ts = fso.CreateTextFile(strFile)
ts.Close
End If
Set ts = fso.OpenTextFile(strFile, ForAppending)
ts.Write strText
ts.Close
ExitHere:
On Error Resume Next
Set ts = Nothing
Set fso = Nothing
Exit Sub
ErrHandler:
MsgBox "Error " & Err & " - " & Err.Description
Resume ExitHere
End Sub