Hi All,
I know how to create a text file and how to write in them. Is there any way to update them? i mean not to overwrite the file but to add another lines?
Please help.
Thanks,
Ajit
Yes, Open your file in append mode instead of write mode.
(03-05-2010 12:05 PM)Saket Wrote: [ -> ]Yes, Open your file in append mode instead of write mode.
Hi Saket,
I am trying as you have said but getting the invalid call procedure or argument.
My code is:
Dim fso, tf
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FileExists ("c:\testfile.txt")) = True Then
Set tf = fso.OpenTextFile("c:\testfile.txt", ForAppending, True)
Else
Set tf = fso.CreateTextFile("c:\testfile.txt", True)
End If
' Write a line with a newline character.
' tf.WriteLine("CashOnHand TotalPortfolioWorth ShareHoldingValue")
' Write a line.
tf.Write (CashOnHand&" "&TotalPortfolioWorth&" "&ShareHoldingValue)
tf.Close
Please correct me where i am wrong.
Thanks;
Ajit
you have not defined 'ForAppending' anywhere in the code
add 'ForAppending = 8' this line at top. or
use below statement -
Set tf = fso.OpenTextFile("c:\testfile.txt", 8, True)
(03-05-2010 02:14 PM)Saket Wrote: [ -> ]you have not defined 'ForAppending' anywhere in the code
add 'ForAppending = 8' this line at top. or
use below statement -
Set tf = fso.OpenTextFile("c:\testfile.txt", 8, True)
Great Saket. It worked. but what was the reason of not running of the old line?
Thanks,
Ajit