Wikipedia

Search results

Sunday 22 December 2013

Move Files from a folder to destination folder with VBA...



Sub movefile()
Dim fso As Object
Dim Mfile As File
Dim Sfldr As Folder
Dim Dfldr As Folder
    MsgBox "Select Source folder", vbInformation
        With Application.FileDialog(msoFileDialogFolderPicker)
        .Show
        Path = .SelectedItems(1) & "\"
        End With
    MsgBox "Select Destination folder", vbInformation
        With Application.FileDialog(msoFileDialogFolderPicker)
        .Show
        dpath = .SelectedItems(1) & "\"
        End With
       
    Set fso = New FileSystemObject
    Set Sfldr = fso.GetFolder(Path)
        For Each Mfile In Sfldr.Files
            Mfile.Move dpath & Mfile.Name
        Next
End Sub

regards,

Vikas Verma

No comments:

Post a Comment