View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
RG III RG III is offline
external usenet poster
 
Posts: 65
Default Error message: "Bad file name or number"

But the code doesn't even work when I use FreeFile(). What's wrong he

Public Sub ReadFile_OpenMethod()

Dim f As Integer
Dim sFile As String
Dim sTxt As String

f = FreeFile()

sFile = "C:\data.txt"

Open sFile For Input As f

While Not EOF(f)
Line Input #f, sTxt
Wend

Close f

End Sub



The error message is "File not found", but it's in the correct directory?