Need help with VBA read file insntructionns – what’s the best way to do it? or Struggling with VBA re

14 Replies, 1128 Views

Ugh, I remember banging my head against vba read file insntructionns too. The `FileSystemObject` method is way cleaner IMO. You’ll need to enable "Microsoft Scripting Runtime" in Tools > References first.

```vba
Dim fso As New FileSystemObject
Dim file As TextStream
Set file = fso.OpenTextFile("C:\yourfile.txt", ForReading)

Do Until file.AtEndOfStream
Debug.Print file.ReadLine
Loop

file.Close
```

Less error-prone than the `Open` method, and way more readable. Give it a shot!

Messages In This Thread



Users browsing this thread: 1 Guest(s)