ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to overwrite data in file? (https://www.excelbanter.com/excel-programming/437286-how-overwrite-data-file.html)

Joe User[_2_]

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?



All times are GMT +1. The time now is 02:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com