Sub Test1()
Application.DisplayAlerts = False
dirPath = ThisWorkbook.Path & "\"
csvName = Dir(dirPath & "*.csv")
Do While csvName <> ""
Workbooks.Open (dirPath & csvName)
'
'(主程式)
'
ActiveWorkbook.Close savechanges:=False
csvName = Dir
Loop
Sub Test2()
Application.DisplayAlerts = False
Sheets(1).Activate
Columns("V").Clear
dirPath = ThisWorkbook.Path & "\"
csvName = Dir(dirPath & "*.csv")
n = 0
Do While csvName <> ""
n = n + 1
Cells(n, 22) = csvName
csvName = Dir
Loop
MsgBox "檔案數=" & n
For i = 1 To n
csvfile = Sheets(1).Cells(i, 22)
Workbooks.Open (dirPath & csvfile)
'
'(主程式)
'
ActiveWorkbook.Close savechanges:=False
next i
End Sub作者: Hsieh 時間: 2010-9-7 18:00