How to overwrite data in file?

J

Joe User

I am using a text file to log progress of a long-running macro.

I want to continuously overwrite the first line with variable-length data.

The following paradigm demonstrates my problem:

Open myPath For Output Access Write As #fd
Print #fd, "1234567890123456789012345678901234567890"
Seek #fd, 1
Print #fd, "abcde"
Close #fd

I want the file to contain only "abcde". But the actual result is:

abcde
890123456789012345678901234567890

Apparently, "abcde" CRLF overwrote the data, but that did not cause the
end-of-file to be rewritten.

How can I cause the end-of-file to be rewritten?
 

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