我目前有一个包含1,000多个csv文件的文件夹。我希望能够遍历所有文件并简单地分隔它们。每次我运行这个脚本,我都可以打开和关闭文件但是当我添加分隔部分时没有任何反应。我在这段代码中遗漏了哪些明显的东西?
''Open all files and delimit
Sub OpenFiles()
Dim MyFolder As String
Dim MyFile As String
'Open Files
MyFolder = "C:\Users\Test\Documents\Test"
MyFile = Dir(MyFolder & "\*.csv")
Do While MyFile <> ""
Workbooks.Open Filename:=MyFolder & "\" & MyFile
'Delimit CSV files
Columns("A:A").TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=True, Space:=False, Other:=False, FieldInfo _
:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), _
Array(7, 1)), TrailingMinusNumbers:=True
ActiveWorkbook.Close True
MyFile = Dir
Loop
End Sub