VBA編程怎麼寫指定文件夾路徑並依次打開符合後綴名要的文件
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
請問高人 vba中選擇文件的路徑和文件名放在哪個控件中怎麼實現
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編程指定文件夾路徑並按順序打開符合特定後綴名的文件的詳細內容,更多請關注本站其它相關文章!