The TextStream Object : TextStream « File Path « VBA / Excel / Access / Word






The TextStream Object

 
Sub CreateTxtFile()
    Dim myFileSystemObject As FileSystemObject
    Dim aFile As TextStream

    Set myFileSystemObject = New FileSystemObject
    Set aFile = myFileSystemObject.CreateTextFile("C:\myFile.txt", True)
    aFile.WriteLine
    aFile.Write ("asdf")    'Write tab-delimited text

    aFile.Close         'Close file and clear memory
    Set myFileSystemObject = Nothing
    Set aFile = Nothing
End Sub

 








Related examples in the same category

1.Read text file
2.On Error/Goto and the Err Object