I need to add text string in the end, to all files on a folder
For example, on the folder on the path and called C:\folder\ I have a random number of txt files, with text. I want to add a line for example "text" on each of the text files on the folder
I have little knowledge of vba programming, but for what I have read I can use append, but I need something that loop on the files on the folder, and modify them.
So far I tried this:
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;">
Sub footer()
Dim FolderPath AsString
Dim FileName AsString
Dim wb As Excel.Workbook
FolderPath ="C:\folder\"
FileName = Dir(FolderPath)
DoWhile FileName <>""
Open FileName For Append As#1
Print #1,"test"
Close #1
FileName = Dir
Loop
EndSub
</code>But seems that its not looking into the files, or appending the text.
All the files on the folder are created by another vba code, and the issue I have is that unless I do like a list of those files, I have not figure it out how to append the text without knowing the list.
For example, on the folder on the path and called C:\folder\ I have a random number of txt files, with text. I want to add a line for example "text" on each of the text files on the folder
I have little knowledge of vba programming, but for what I have read I can use append, but I need something that loop on the files on the folder, and modify them.
So far I tried this:
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;">
Sub footer()
Dim FolderPath AsString
Dim FileName AsString
Dim wb As Excel.Workbook
FolderPath ="C:\folder\"
FileName = Dir(FolderPath)
DoWhile FileName <>""
Open FileName For Append As#1
Print #1,"test"
Close #1
FileName = Dir
Loop
EndSub
</code>But seems that its not looking into the files, or appending the text.
All the files on the folder are created by another vba code, and the issue I have is that unless I do like a list of those files, I have not figure it out how to append the text without knowing the list.