Wednesday, February 9, 2011

Append to an existing text file

'Append to an existing text file
On Error Resume Next
dim objFSO
dim objFile

Const ForAppending=8
'specify filename and path for file to open
strFile="c:\file.txt"

set objFSO=CreateObject("Scripting.FileSystemObject")
set objFile=objFSO.OpenTextFile(strFile,ForAppending)
objFile.WriteLine Now & " this is an appended line"
objFile.Close

set objFile=Nothing
set objFSO=Nothing

No comments: