Good Afternoon All,
After some searching I have found a code that will transfer a folder from one drive to another.
I have put this code on a command button, and I still get an error message "The expression on click you entered as the event property setting produced the following error: Expected End sub"
Can someone please explain where the error is as I have been over the code numerous times and I can not see any error.
Is there also a way to have the results of the browse button I posted earlier to automatically be the FromPath in the code below.
Also is there a way to have the FromPath a Generic C:\User\Desktop so it can be used on any computer?
Thanks in advance.
awade
Private Sub Command0_Click()
Sub Copy_Folder()
Dim FSO As Object
Dim FromPath As String
Dim ToPath As String
FromPath = "C:\Users\Wadey\Desktop\Engine Data.zip"
ToPath = "S:\eDNA\admin\eDNA\Engine Data"
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 & "Does Not Exisit"
Exit Sub
End If
If FSO.FolderExists(ToPath) = True Then
MsgBox ToPath & "exisits, not Possible To Move To An Exisiting Folder"
Exit Sub
End If
FSO.MoveFolder Source:=FromPath, Destination:=ToPath
MsgBox "The Folder is moved from" & FromPath & " to " & ToPath
End Sub