Good morning to you all,
I would like to copy the entire folder from K: to P: if the folder does not exist.
And then copy the existing folders from K to P.
I started with the non-existent files but it does not perform creation.
I would like to copy the entire folder from K: to P: if the folder does not exist.
And then copy the existing folders from K to P.
I started with the non-existent files but it does not perform creation.
Code:
Option Compare Database
Option Explicit
Sub GetSubFolderNames()
Dim MyFSOK As FileSystemObject
'Dim MyFile As File
Dim MyFolderK As Folder
Dim MySubFolderK As Folder
Dim MyFSOP As FileSystemObject
Dim MyFolderP As Folder
Dim MySubFolderP As Folder
Dim FromPath
Set MyFSOP = New Scripting.FileSystemObject
Set MyFSOK = New Scripting.FileSystemObject
Set MyFolderK = MyFSOK.GetFolder("K:\DG")
Set MyFolderP = MyFSOP.GetFolder("C:\Pers1")
FromPath = MyFolderK
For Each MySubFolderK In MyFolderK.SubFolders
If Not MyFSOP.FolderExists(MyFolderK) Then
MyFSOP.CreateFolder (MyFSOK)
Else
End If
Next MySubFolderK
End Sub