Hi All,
I have a bit of code that should go through every file in the folder specified and insert a bit of text. This is fine, except it doesn't work.
Could anyone advise why this doesn't work?
Thanks in advanced.
I have a bit of code that should go through every file in the folder specified and insert a bit of text. This is fine, except it doesn't work.
Could anyone advise why this doesn't work?
Code:
Sub replacetxt()
Dim fso, fol, f
Dim a As String
Set fso = CreateObject("Scripting.filesystemobject")
Set fol = fso.GetFolder("C:\Test\")
For Each f In fol.Files
a = FreeFile
Open f.Name For Output As a
Print #a, "This is new text"
Close a
Next f
Set f = Nothing
Set fol = Nothing
Set fso = Nothing
End Sub
Thanks in advanced.