Reading and writing to/from a text file using TextStreams
Part one of a three-part series of blogs

The easiest way to work with text files in VBA is using TextStream objects - this blog explains how they work.

  1. Reading and Writing Text Files using TextStreams (this blog)
  2. Creating a Text File and Writing Lines
  3. Reading in Lines from a Text File

This blog is part of a complete Excel VBA tutorial, but we also run classroom training courses in VBA.

Posted by Andy Brown on 13 January 2012

You need a minimum screen resolution of about 700 pixels width to see our blogs. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

Reading and Writing Text Files using TextStreams

This blog shows how to read from (and write to) text files using something called TextStream objects.

There is another way to do this in VBA using commands like Input and Open, but I think the way shown here is much easier to remember and use.

In order to get any of the code in this blog to work, you first need to create a FileSystemObject.


  1. Reading and Writing Text Files using TextStreams (this blog)
  2. Creating a Text File and Writing Lines
  3. Reading in Lines from a Text File
This blog has 0 threads Add post