Sub Test()
Dim myPath As String, MyName As String
myPath = "C:\Documents\" 'Get Path
MyName = Dir(myPath) 'find the first file
#If Right(MyName, 4) = ".csv" Then Workbooks.Open Filename:=myPath & MyName
Do While MyName ""
MyName = Dir 'find next
If Right(MyName, 4) = ".csv" Then Workbooks.Open Filename:=myPath & MyName
Loop
End Sub
Sub DateSave()
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:= _
ThisWorkbook.Path & "\" & Date & ".xls", _
FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
Application.DisplayAlerts = True
End Sub
請將“ThisWorkbook.Path & "\" & Date & ".xls", _”改為“"d:\" & Date & ".xls", _”,其中“"d:\" ”就是你要存的路徑。
希望我的回答對你有幫助。
以上是如何使用VBA編程指定資料夾路徑並依序開啟符合特定後綴名的文件的詳細內容。更多資訊請關注PHP中文網其他相關文章!