View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Richard Mogy Richard Mogy is offline
external usenet poster
 
Posts: 27
Default Text file open and close VBA

First issue --- You can't read (line input #1) an output, you can only read
files open for input.
"Karpgam" wrote in message
...
Hi

I am new to VBA development, I have text file and opening
text file in my VBA to read. After that i want to Add new
line, so i Open it for output mode, (I will create delete
existing and create new file that is ok for me). Here is
my code

Open sXferFile For Output As #1
While Not EOF(1)
Line Input #1, stemp
sFileName = stemp
Line Input #1, stemp
' sProcessDate = CDate(STEMP)
sProcessDate = stemp
Wend
close #1
-- after this
sfnum = freefile
Open sXferFile For Output As #sFnum
write #sfnum, "Over"
close #sfnum


I am getting Path/file error when i open it after closing
text file.

Need help?

Thanks
kalyan