LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 417
Default Write Additional Data within a txt File

<<I want to open a txt file, read it until I find a line that contains
certain info and then append additional data on to that line. The line may
be in the middle of the file. How can I do this?

Depends on how big the file is. For a small file, use the OpenText method
to import into a worksheet, find the line that needs to be appended or
changed, then SaveAs to a new text file.

For a file that is too big to fit on a worksheet, then you will have to use
either "Microsoft Scripting Runtime" or "Windows Script Host Object Model".
Set a reference to one of them in the Tools|References dialog box. Both of
them have FileSystemObject and TextStream objects available. Open the file,
copy lines to a new file until you come to the line to be changed, change
it, write it out, and continue copying lines. Download the Microsoft
Windows Script Help file (SCRIPT56.CHM) for additional details.
--
Regards,
Bill Renaud



 
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
Write data in a closed file? Nicolas[_3_] Excel Programming 1 February 2nd 07 02:47 AM
Write data in a closed file? Nicolas[_3_] Excel Programming 1 February 1st 07 01:26 AM
Open CSV file, format data and write output to a text file. BristolBloos Excel Programming 1 October 18th 05 03:50 PM
Push/write data into an unopened file Rod Excel Worksheet Functions 2 March 27th 05 03:29 PM
Write data to access file through EXCEL Billy[_2_] Excel Programming 0 December 1st 03 03:22 AM


All times are GMT +1. The time now is 12:40 PM.

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

About Us

"It's about Microsoft Excel"