0
我已经为读取txt文件创建了一个代码,并删除了该文件中的一组行并将其保存在另一个位置。您能否帮我修改读取特定文件夹中多个文件的代码,然后对所有文件执行该过程,并将这些文件保存在不同文件夹中的同名文件中。我附上了代码。处理文件夹中的多个文件,并使用vba放置在具有相同文件名的不同文件夹中
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
在此先感谢
[this](http://stackoverflow.com/questions/10380312/loop-through-files-in-a-folder-using-vba)将有所帮助。在问这个问题之前,你甚至搜索过解决方案吗? –