Problem to open file

Hi,
I get this problem
tt514.pngdue to last 2nd line below
    If Dir(File0) = "" Then
        Set f = fs.createtextfile(File0)
    Else
        Set f = fs.OpenTextFile(File0, 3, TristateFalse)
    End If

Open in new window

Why?
LVL 12
HuaMin ChenProblem resolverAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gustav BrockCIOCommented:
Try with:
    ForAppending = 8
    TristateFalse = 0
    If Dir(File0) = "" Then
        Set f = fs.createtextfile(File0)
    Else
        Set f = fs.OpenTextFile(File0, ForAppending, TristateFalse)
    End If

Open in new window

/gustav

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HuaMin ChenProblem resolverAuthor Commented:
Many thanks.
I want to further read all the lines, from the text file. Any example?
Gustav BrockCIOCommented:
Oh, numerous - just bing/google on that.

/gustav
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

HuaMin ChenProblem resolverAuthor Commented:
Using these

    Dim fs, f
    Set fs = CreateObject("Scripting.FileSystemObject")
    File0 = ActiveWorkbook.Path & "\MonthStatus.txt"
    
    Dim iFile As Integer: iFile = FreeFile
    Open File0 For Input As #iFile
    Do Until EOF(1)
        Line Input #1, TextLine
        
        MsgBox TextLine
        If Trim(TextLine) <> "" Then
            ...
        End If
    Loop

Open in new window

I cannot read the lines inside the file. Why?
Gustav BrockCIOCommented:
A little more precision is needed:
    Dim fs, File0, TextLine
    Set fs = CreateObject("Scripting.FileSystemObject")
    File0 = ActiveWorkbook.Path & "\MonthStatus.txt"
    
    Dim iFile As Integer: iFile = FreeFile
    Open File0 For Input As #iFile
    Do Until EOF(iFile)
        Line Input #iFile, TextLine
        
        MsgBox TextLine
        If Trim(TextLine) <> "" Then
        '    ...
        End If
    Loop

Open in new window

/gustav
Gustav BrockCIOCommented:
Grade B? What was missing, please?

/gustav
Paul SauvéRetiredCommented:
Grade B? What was missing, please?

Again! The answer is NOT the problem!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.