How to add data into a text file without overwriting existing data

J

J@Y

I'm using

Print FileNumber, LineofText

to copy one line of text from one text file to another text file. If I close
the file and reopen them to write again, the previous data gets erased. How
do I open the write file so what is already in it stays and what I add to it
follows ?
 
C

Chip Pearson

What you didn't include in your message was your Open statement. If you open
the destination file for Output, existing contents are destroyed. If you
open it for Append, new content is added to the end of the file.

Open "C:\Test.txt" For Append Access Write As #FileNum


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)
 
J

J@Y

Excellent. Thanks, the Append worked.

Chip Pearson said:
What you didn't include in your message was your Open statement. If you open
the destination file for Output, existing contents are destroyed. If you
open it for Append, new content is added to the end of the file.

Open "C:\Test.txt" For Append Access Write As #FileNum


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top