Text file open and close VBA
And how is freefile populated?
wrote in message
...
Hi
Sorry I wrongly pasted my code actual code will be like
this
FOLLOWING PART WORK FINE
Open sXferFile For input As #1
While Not EOF(1)
Line Input #1, stemp
sFileName = stemp
Line Input #1, stemp
sProcessDate = stemp
Wend
close #1
AFTER CLOSE, WHEN I OPEN FOR OUTPUT I GOT ERROR
sfnum = freefile
Open sXferFile For Output As #sFnum
write #sfnum, "Over"
close #sfnum
I KNOW IF I OPEN EXISTING FILE FOR OUTPUT, THAT WILL
DELETE AND RECREATE THAT IS FINE, BUT IT IS NOT BEHAVING
LIKE THAT, SIMPLY GIVE ERROR Path/file error
THANKS
KALYAN
-----Original Message-----
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
.
|