I want to generate a log while my VBA program runs. Firstly, I initialize the log file and add a title. This works. Then, I want to add info (AddinfoLog). When I open the textfile in MS Wordpad, I see Chinese character intead of "test" on the last row. When I change the 8 to a 2 to write (and supersede the original file) as a test, I see "test" in the file, which is correct.
In each case, when opening the txt file in the MULTI Editor, i always see "test", and never the Chinese characters.
How can I solve this problem?
Code:
In each case, when opening the txt file in the MULTI Editor, i always see "test", and never the Chinese characters.
How can I solve this problem?
Code:
Code:
Public fso As FileSystemObject
Public FSOFile As TextStream
Public LogPath As String
Sub InitializeLog()[INDENT]Set fso = New FileSystemObject
LogPath = mainfolder & "\Log.txt"
Set FSOFile = fso.CreateTextFile(LogPath, 1, True)
FSOFile.WriteLine "Title"
FSOFile.WriteLine "Generation started on " & Date & " at " & Time
FSOFile.Close[/INDENT]
End Sub
Sub AddinfoLog()
[INDENT]Set fso = New FileSystemObject
LogPath = mainfolder & "\Log.txt"
Set FSOFile = fso.OpenTextFile(LogPath, 8, True) '2 for write, 8 for append 'else error bad file mode
FSOFile.WriteLine "test"
FSOFile.Close[/INDENT]
End Sub