ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   FileSystemObject question (https://www.excelbanter.com/excel-programming/273294-filesystemobject-question.html)

Tod

FileSystemObject question
 
This is kinda sorta the right NG for this question.

My code is appending to a text file each day, like this:

Set fso = CreateObject("Scripting.FileSystemObject")
Set txtStream = fso.OpenTextFile("C:\Path\Log.txt", 8)
txtStream.WriteLine (Now & ": File Updated")
txtStream.Close

The log file gets updated about five times each day, so
the file gets longer each time. I'd like to have code that
deletes x number of entries from the top of the list. How
do I do that?

tod


Don Guillett[_4_]

FileSystemObject question
 
really a row delete question?
rows(1:5).delete

--
Don Guillett
SalesAid Software
Granite Shoals, TX

"Tod" wrote in message
...
This is kinda sorta the right NG for this question.

My code is appending to a text file each day, like this:

Set fso = CreateObject("Scripting.FileSystemObject")
Set txtStream = fso.OpenTextFile("C:\Path\Log.txt", 8)
txtStream.WriteLine (Now & ": File Updated")
txtStream.Close

The log file gets updated about five times each day, so
the file gets longer each time. I'd like to have code that
deletes x number of entries from the top of the list. How
do I do that?

tod




Steve Yandl[_3_]

FileSystemObject question
 
Tod,

I think I'd ask this one in the vbscript newsgroup.

If you're going to do this with scripting, you probably should create an
array, reading the text file a line at a time to add elements to the array
as strings. This way you can establish a set number of lines you want to
retain. After the array is complete, delete the old log file and build a
new one, deleting the first elements to retain the number of lines you want.

Steve


"Tod" wrote in message
...
This is kinda sorta the right NG for this question.

My code is appending to a text file each day, like this:

Set fso = CreateObject("Scripting.FileSystemObject")
Set txtStream = fso.OpenTextFile("C:\Path\Log.txt", 8)
txtStream.WriteLine (Now & ": File Updated")
txtStream.Close

The log file gets updated about five times each day, so
the file gets longer each time. I'd like to have code that
deletes x number of entries from the top of the list. How
do I do that?

tod




Tom Ogilvy

FileSystemObject question
 
As you suspected,
Read the file into a variable, open it for write and write it out minus the
first five lines

or open it in excel, delete the rows and save it.

Regards,
Tom Ogilvy


Tod wrote in message
...
This is kinda sorta the right NG for this question.

My code is appending to a text file each day, like this:

Set fso = CreateObject("Scripting.FileSystemObject")
Set txtStream = fso.OpenTextFile("C:\Path\Log.txt", 8)
txtStream.WriteLine (Now & ": File Updated")
txtStream.Close

The log file gets updated about five times each day, so
the file gets longer each time. I'd like to have code that
deletes x number of entries from the top of the list. How
do I do that?

tod





All times are GMT +1. The time now is 03:39 PM.

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