Open hidden txt files with VBA Open statement


in an Excel 2003 vba function I'm trying to open a normal txt file like this:
Open filename for input as #1

It works fine until I hide the file (using explorer's file properties). When the file is hidden, the function can't find it anymore... what am I missing? How can I retrieve it when is hidden?

Who is Participating?
Robberbaron (robr)Commented:
you had shown INPUT #1 in your Q.

Yes OUTPUT fails with Path/File Access error when file exists and is hidden.
resolution is easy enough....

Sub SendOut()
    Dim flpath As String
    flpath = "c:\work\ee\test1.txt"
    If GetAttr(flpath) And vbHidden Then          'check for hidden
        SetAttr flpath, GetAttr(flpath) - vbHidden
    End If
    Open flpath For Output As #1
        Print #1, "test2"
    Close #1
    SetAttr flpath, GetAttr(flpath) Or vbHidden     'set to hidden
End Sub
Is there anything special about your function that you haven't mentioned?  I just tried it and the code that you are using will open and read a text file just fine in a sub procedure, even if it is hidden with explorer's file properties...
Are you sure you didn't accidently change the name or location of the file in Explorer or your code?
Is there anything else that you can tell us...maybe paste your problem code here for us to see...

jiiins2Author Commented:
Here is the code:

flFees = ThisWorkbook.Path & "\fees.txt"
Open flFees For Output As #1                    <- here I get run-time error 75

If I unhide fees.txt it works fine.
jiiins2Author Commented:
Thanks for the quick answer and sorry for my confused input/output question!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.