I want to create a text file using VBA. If I select a folder, the VBA code will write all folders, filenames to a text file (text.txt)
The codes below write the text.txt but for some reason, the first line shows OK and the rest are in special characters. Does anyone have any ideas?
Thanks,
XT
'========================================================
Dim fs
Dim a
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set fs = CreateObject("Scripting.FileSystemObject")
If (fs.FileExists("c:\text.txt")) = False Then
Set a = fs.CreateTextFile("c:\text.txt", ForWriting, True)
a.WriteLine (strName)
Else
Set a = fs.OpenTextFile("c:\text.txt", ForAppending, True)
a.WriteLine (strName)
End If
'a.Close
Set a = Nothing
Set fs = Nothing
'========================================================
The codes below write the text.txt but for some reason, the first line shows OK and the rest are in special characters. Does anyone have any ideas?
Thanks,
XT
'========================================================
Dim fs
Dim a
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set fs = CreateObject("Scripting.FileSystemObject")
If (fs.FileExists("c:\text.txt")) = False Then
Set a = fs.CreateTextFile("c:\text.txt", ForWriting, True)
a.WriteLine (strName)
Else
Set a = fs.OpenTextFile("c:\text.txt", ForAppending, True)
a.WriteLine (strName)
End If
'a.Close
Set a = Nothing
Set fs = Nothing
'========================================================