2

So I've got this code

Dim fpath As String
fpath = "D:\stats.csv"
Open fpath For Append As #fw

However when I am trying to run it I am getting a run-time error '52': Bad file name or number.

I have no idea what I am doing wrong, maybe it's a Office 2016/Windows 10 glitch that I am not aware of.

Thanks in advance for your help

0

1 Answer 1

2

You need fw to be a valid file identifier number. To do so, get an identifier from the function FreeFile:

Dim fpath As String, fw As Long
fw = FreeFile                   ' <--------- get a valid file identifier
fpath = "D:\stats.csv"
Open fpath For Append As #fw
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.