Private Type SHFILEOPSTRUCT
hWnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAborted As Boolean
hNameMaps As Long
sProgress As String
End Type
Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Const FOF_NOCONFIRMATION = &H10 ' Don't prompt the user.
Const FOF_NOCONFIRMMKDIR = &H200 ' don't confirm making any needed dirs
Const FO_COPY = &H2
Private Function NuCopy(source As String, target As String) As Boolean
'Nucleus
'Copy file(s)/directories from source to destination
'In path of source either file(s) or folder and path of target as folder
'Out: Boolean indicating success
If Right(source, 1) = "\" Then source = Left(source, Len(source) - 1)
If Len(Dir$(target, vbDirectory)) <> 0 And (Len(Dir$(source, vbDirectory)) <> 0 Or Len(Dir$(target, vbDirectory)) <> 0) Then
Dim SHFileOp As SHFILEOPSTRUCT ' structure to pass to the function
With SHFileOp
.wFunc = FO_COPY
.pFrom = source
.pTo = target
.fFlags = FOF_NOCONFIRMATION Or FOF_NOCONFIRMMKDIR
End With
NuCopy = (SHFileOperation(SHFileOp) = 0)
End If
End Function