RobbieC
Active Member
- Joined
- Dec 14, 2016
- Messages
- 376
- Office Version
- 2010
- Platform
- Windows
Hi there, I have a bit of VBA code (from Ron de Bruin) which successfully copies folders in a directory to another:
I can see that this line does the business:
But I have 2 folders named 'NotToCopy' & 'NotToCopyEither' which I want to exclude from this procedure
Can anyone point me in the right direction for this? If you can, I'd be very grateful
Thanks
VBA Code:
Sub Copy_Folder()
Dim FSO As Object
Dim FromPath As String
Dim ToPath As String
FromPath = "C:\MyFolder"
ToPath = "C:\MyBackUpFolder"
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
I can see that this line does the business:
VBA Code:
FSO.CopyFolder Source:=FromPath, Destination:=ToPath
But I have 2 folders named 'NotToCopy' & 'NotToCopyEither' which I want to exclude from this procedure
Can anyone point me in the right direction for this? If you can, I'd be very grateful
Thanks