VBA CreateTextFile

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)

The FileSystemObject VBA CreateTextFile creates a text file and returns a TextSteam object that allows you to read and write to the file.

VBA CreateTextFile Syntax

Name of the file to create. Be sure to add .txt extension to be able to open in text editor by default.
Optional. If True will overwrite a file with same name.
Optional. If True then Unicode file will be created. If False then ASCII. By default ASCII file is created.

VBA CreateTextFile Examples

Write a line to text file with New Line (late binding)

This is the result:

Write a string to text file w/o new line (early binding)

Below a different procedure this time with Early Binding and writing a string without a New Line character at the end.

This is the result:

Simply the best place to learn Excel VBA