Well...
A easy one.
I want to write to
an existing file, with
out deleting the old
contents. I just want to
add a string like "Test"
on the next line.
Printable View
Well...
A easy one.
I want to write to
an existing file, with
out deleting the old
contents. I just want to
add a string like "Test"
on the next line.
this example should help:
Code:Option Explicit
Private Sub Command1_Click()
Static i As Integer
Dim filename As String
Dim fnum As Byte
filename = "c:\ttt.txt"
fnum = FreeFile
Open filename For Append As fnum
Print #fnum, "extra line " & i
Close fnum
i = i + 1
End Sub
You could also use the Microsoft Scripting Runtime Library.
Then your code would be like this
Dim fsObject as new FileSystemObject
dim fsTextStream as TextStream
Set fsTextStream = fsObject.OpenTextFile("TestkFileName")
fsTextStream.AtEndOfStream
fsTextStream.WriteLine 'Place your line here
fsTextStream.Close
Set fsObject = Nothing
Set fsTextStream = Nothing
Yeah don't bother with my suggestion! it actually works.
try jeroenh's which doesn't
I could probably post a few hundred lines of code using APIs which does the same thing as well.
After all, the more code the better eh?!!!!