2022年1月12日 星期三

VBA_移動檔案_資料夾

移動檔案,整個資料夾移動, 


Sub 移動檔案_資料夾()

'2022/1/12  21:56

Application.ScreenUpdating = False


Dim objFile As File

Dim objFolder As Folder

Dim objFSO As FileSystemObject

Dim in_原始夾 As String

Dim in_目標夾 As String

in_原始夾 = "C:\Users\arthur\Desktop\C槽桌面\TESTA"

in_目標夾 = "C:\Users\arthur\Desktop\C槽桌面\TEST"

Set objFSO = New FileSystemObject

Set objFolder = objFSO.GetFolder(in_原始夾)


For Each objFile In objFolder.Files

'If (objFile.Name <> ThisWorkbook.Name) And (InStr(1, objFile.Name, ".xls") Or InStr(1, objFile.Name, ".csv")) Then

objFile.Move (in_目標夾 & "\" & objFile.Name)

'End If


Next objFile


End Sub

沒有留言:

張貼留言