Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tod Tod is offline
external usenet poster
 
Posts: 13
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default 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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 Macro/VB Question DDE Question MadDog22 Excel Worksheet Functions 1 March 10th 10 01:47 AM
where can I see my question and answer? Yesterday I ask a question IP Excel Discussion (Misc queries) 2 May 10th 08 04:08 PM
Newbie Question - Subtraction Formula Question [email protected] Excel Discussion (Misc queries) 3 May 5th 06 05:50 PM
Scripting.FileSystemObject Leif Rasmussen Excel Discussion (Misc queries) 1 January 12th 05 11:21 PM
FileSystemObject to get last 10 lines of text file. john Excel Programming 11 July 16th 03 03:54 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"