Hello,
I have below source of code which copies files from Shared drive and pastes to Online SharePoint.
But every time, we need to change the path location in VBA code i.e. FromPath and ToPath (because of multiple folders)
Is there a way where users can simple enter the path location in excel spreadsheet, rather than going to Visual basic Window.
For "FromPath" - Enter path location in B1 Cell and for "ToPath" enter path location in B2 cell
Thanks,
Prakash
I have below source of code which copies files from Shared drive and pastes to Online SharePoint.
But every time, we need to change the path location in VBA code i.e. FromPath and ToPath (because of multiple folders)
Is there a way where users can simple enter the path location in excel spreadsheet, rather than going to Visual basic Window.
For "FromPath" - Enter path location in B1 Cell and for "ToPath" enter path location in B2 cell
Code:
Sub Rectangle4_Click()
Dim fso As Object
Dim FromPath As String
Dim ToPath As String
FromPath = "\\pu4\\"
ToPath = "\Shared Documents\2020"
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 & " Path doesn't exist"
Exit Sub
End If
fso.CopyFolder Source:=FromPath, Destination:=ToPath
MsgBox " Hi you can find the files in " & ToPath
End Sub
Thanks,
Prakash
Last edited by a moderator: