I have this code that moves a folder from the current path to the local disk: \ C The problem I have when the current path of the database is in a disk other than the: \ C Gives a permission denied message This is the code:
<Private Sub Form_Load()
On Error GoTo MyErr
Dim FSO As Object
Dim FromPath As String
Dim ToPath As String
FromPath = CurrentProject.Path & "\MyFolder"
ToPath = "C:\MyFolder"
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
Exit Sub
End If
If FSO.FolderExists(ToPath) = True Then
Exit Sub
End If
FSO.MoveFolder Source:=FromPath, Destination:=ToPath
MyErr: If Err.Number <> 0 Then
MsgBox Err.Number & " - " & Err.Description
End If
End Sub
So what is the solution ???