|
从txt文件批量提取到excel中,老是 Open f For Input As #1 这一句“运行时错误“70‘’”,拒绝的权限”,点结束也可以得到想要的结果,有没有什么办法去掉这个错误提示,请各位老是指点一下
Sub 批量提取txt()
Application.ScreenUpdating = False
Range("a2:g" & Rows.Count).ClearContents
a = 2
Set fso = CreateObject("scripting.filesystemobject")
Set ff = fso.getfolder(ThisWorkbook.Path)
For Each f In ff.Files
If f.Name <> ThisWorkbook.Name Then
Open f For Input As #1 “运行时错误“70‘’”,拒绝的权限”
While Not EOF(1)
Line Input #1, str1
If str1 > 0 Then
Cells(a, 1) = str1
a = Cells(Rows.Count, 1).End(3).Row
a = a + 1
End If
Wend
Close #1
End If
Next f
Application.ScreenUpdating = True
End Sub
|
|