I get a "path not found" error when I try to copy a directory (strFolder) that has spaces in its name. Both folders are exists. How to work around this limitation?
Sub foldecopytest()
Dim objFSO, strFolder, strToPath
strFolder = "f:\Logistics Manager\Invoice\22000741 KlientID\"
strToPath = "\\10.224.73.57\Database\Logistics\Invoice\"
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFolder strFolder, strToPath
End Sub
Remove the ending \
from both of the folder paths.
Sub foldecopytest()
Dim objFSO As Object, strFolder As String, strToPath As String
strFolder = "f:\Logistics Manager\Invoice\22000741 KlientID"
strToPath = "\\10.224.73.57\Database\Logistics\Invoice"
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFolder strFolder, strToPath
End Sub
If you want to copy over the whole folder and not just the contents:
Sub foldecopytest()
Dim objFSO As Object, strFolder As String, strToPath As String
strFolder = "f:\Logistics Manager\Invoice\22000741 KlientID"
strToPath = "\\10.224.73.57\Database\Logistics\Invoice"
Set objFSO = CreateObject("Scripting.FileSystemObject")
With objFSO.GetFolder(strFolder)
.Copy strToPath & "\" & .Name
End With
End Sub