View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Joe User[_2_] Joe User[_2_] is offline
external usenet poster
 
Posts: 905
Default How to overwrite data in file?

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?