naveenraja16
New Member
- Joined
- Mar 3, 2016
- Messages
- 10
Hi,
I have made a code for reading a txt file and delete a set of lines in that file and save it in another location. Can you help me out in modifying the code for reading multiple files present in a particular folder and then do the process on all files and save those files with the same name in a different folder .I have attached the code herewith.
Sub cleantext()
Dim lineOfText As String
Dim skipLines As Boolean
'Open files for writing
Open "C:\Users\INNAR1\Desktop\input_static_files\ebb_htr01h.UCBG" For Input As #1
Open "C:\Users\INNAR1\Desktop\output_static_files\ebb_htr01h.UCBG" For Output As #2
skipLine = False
Do Until EOF(1)
Line Input #1, lineOfText
If lineOfText = "dynamics" Then skipLines = True
If lineOfText = "end dynamics" Then skipLines = False
If Not skipLines And Not lineOfText = "end dynamics" Then Print #2, lineOfText
Loop
Close #1
Close #2
End Sub
Thanks in advance
I have made a code for reading a txt file and delete a set of lines in that file and save it in another location. Can you help me out in modifying the code for reading multiple files present in a particular folder and then do the process on all files and save those files with the same name in a different folder .I have attached the code herewith.
Sub cleantext()
Dim lineOfText As String
Dim skipLines As Boolean
'Open files for writing
Open "C:\Users\INNAR1\Desktop\input_static_files\ebb_htr01h.UCBG" For Input As #1
Open "C:\Users\INNAR1\Desktop\output_static_files\ebb_htr01h.UCBG" For Output As #2
skipLine = False
Do Until EOF(1)
Line Input #1, lineOfText
If lineOfText = "dynamics" Then skipLines = True
If lineOfText = "end dynamics" Then skipLines = False
If Not skipLines And Not lineOfText = "end dynamics" Then Print #2, lineOfText
Loop
Close #1
Close #2
End Sub
Thanks in advance