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中文网其他相关文章!