Question

Locked

VBA - How can I add a line of text to the last line of a text file?

By polinimz ·
Using VBA (MS Access module), I want to open an existing text file and add a row of text to the end of the file. I cannot seem to accomplish this with a simple Open/Write command... Do I need to use the FileSystemObject? If so, any quick suggestions?

Thanks in advance

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

I have solved this...

by polinimz In reply to VBA - How can I add a lin ...

More simple than I could have hoped, I simply opened the file in APPEND mode as opposed to opening for INPUT...

OPEN "textfile.txt" FOR APPEND as #1

Collapse -

if you're doing more changes

by Dr Dij In reply to I have solved this...

then create a second file, open it and read the recs in first file, writing second either changed or unchanged as needed. and adding any at end.

We use this when we need to backup file.
Then rename the orig to .bak using vb fuctions and rename the new file to the orig.

you can also read the directory and process all files or all files with a certain extension if you need to, opening each or any of them sequentially.

Back to Software Forum
3 total posts (Page 1 of 1)  

Software Forums