• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Copy folder from one location to another

Rajender

Member
Hi All,

I have found the below mentioned code by google to copy the files from a particular location to another :-
But its showing error while I am changing the Frompath: to "https://abc.internal.abc.com/sites/Documents/N4S>" that path does not exists.

Also when I am running same code in local drive its working.
Please suggest if for "http" another code needed ?

Thanks in advance.

Code:
Sub Copy_Folder()

    Dim FSO As Object
    Dim FromPath As String
    Dim ToPath As String

    FromPath = "C:\Users\abc\Desktop\Copy"  '<< Change
    ToPath = "C:\Users\abc\Desktop\Move"    '<< Change

    If Right(FromPath, 1) = "\" Then
        FromPath = Left(FromPath, Len(FromPath) - 1)
    End If

    If Right(ToPath, 1) = "\" Then
        ToPath = Left(ToPath, Len(ToPath) - 1)
    End If

    Set FSO = CreateObject("scripting.filesystemobject")

    If FSO.FolderExists(FromPath) = False Then
        MsgBox FromPath & " doesn't exist"
        Exit Sub
    End If

    FSO.CopyFolder Source:=FromPath, Destination:=ToPath
    MsgBox "You can find the files and subfolders from " & FromPath & " in " & ToPath

End Sub

Regards,
Rajender
 
Back
Top