Excel - output to the same line in a Text file?

Asked By Bernard
21-Nov-09 11:57 AM
hi there
How do I output to the same position in a Text file everytime? I want to
dump data for a given Date so I'd like to put it in the same row for that
Date everytime, and so overwrite the existing data in that row?

I am using the following command:

Write #3, logfactor(dateline, 1), logfactor(dateline, 2),
logfactor(dateline, 3)

'where dateline is today's date in Excel date code e.g. 40010

I want to be able to overwrite the existing data for line 40010 in my text
file, and replace it with new data.

Hope that it clear!!!!
thank you
Bernard.
Excel
(1)
Logfactor
(1)
Lengths
(1)
  JLatham replied to Bernard
21-Nov-09 01:45 PM
If, and it is probably a big if, each line in the text file is always exactly
the same length, you could open the file for Binary access, read through it
until you find the beginning of the line you need and replace that line with
the new data.

Barring that, the easiest way is probably to open the existing file for
input, open a second file for output, then
read a line from it,
test if it is the line your want
if not the line you want, write it to the 2nd file
if it is the line you want, write the new data to the 2nd file
and then just read and write from 1st to 2nd to the end of the 1st.
After that you can KILL the 1st file and name the 2nd one with the original
file name.
  Bernard replied to JLatham
25-Nov-09 03:12 PM
Thanks J.
No the lines are different lengths but good thinking. Your idea for using
two files is also good, and workable.
I thought (from recollection of a programming course a long time ago, that
there was a command for output to a record position, but maybe not.
thanks
Bernard.
Create New Account
help
excel Excel excel Excel Discussions Excel (1) ExcelSalesAid (1) GuillettMicrosoft (1) SalesAid (1) Dguillett1 (1) I will certainly try to - - Don Guillett Microsoft MVP Excel SalesAid Software dguillett1@austin.rr.com keywords: excel description: excel
How do I Fill down on Excel Excel Excel Miscellaneous Discussions Excel (1) RegardsDave (1) Hawley (1) http: / / www.ozgrid.com / Excel / excel-fill-handle.htm - - Regards Dave Hawley www.ozgrid.com keywords: How, do, I, Fill, down, on, Excel
excel Excel Excel Discussions Excel (1) You are in the correct news group. Now try a question. Gord Dibben MS Excel MVP keywords: excel
Why doesn't the snap feature work in Excel? Excel Excel Miscellaneous Discussions Microsoft Excel (1) Excel (1) Word (1) Bliengme (1) Snaps (1) SDI (1) Are you referring to Win7's snap feature? My Excel snaps as expected best wishes - - Bernard Liengme Microsoft Excel MVP http: / / people.stfx.ca / bliengme Taken from a post at Microsoft Answers: The snap feature that you are looking for will not work unless you open two instances of Excel. This is because Excel Unlike Word is not a True SDI Application. Microsoft is aware