Option
Explicit
#If VBA7 Then
Private
Declare
PtrSafe
Function
SHFileOperationA
Lib
"shell32.dll"
( _
lpFileOp
As
SHFILEOPSTRUCT)
As
Long
Type SHFILEOPSTRUCT
hwnd
As
LongPtr
wFunc
As
Long
pFrom
As
String
pTo
As
String
fFlags
As
Integer
fAnyOperationsAborted
As
Long
hNameMappings
As
LongPtr
lpszProgressTitle
As
String
End
Type
#Else
Private
Declare
Function
SHFileOperationA
Lib
"shell32.dll"
( _
lpFileOp
As
SHFILEOPSTRUCT)
As
Long
Type SHFILEOPSTRUCT
hwnd
As
Long
wFunc
As
Long
pFrom
As
String
pTo
As
String
fFlags
As
Integer
fAnyOperationsAborted
As
Boolean
hNameMappings
As
Long
lpszProgressTitle
As
String
End
Type
#End If
Private
Const
FN_MOVE = &H1&
Private
Const
FnF_SILENT = &H4&
Private
Const
FnF_RENAMEONCOLLISION = &H8&
Public
Function
VerschiebeOrdner(sQuelle
As
String
, sZiel
As
String
)
As
Long
Dim
FileStructur
As
SHFILEOPSTRUCT
With
FileStructur
.wFunc = FN_MOVE
.pFrom = sQuelle & vbNullChar & vbNullChar
.pTo = sZiel
.fFlags = FnF_RENAMEONCOLLISION + FnF_SILENT
End
With
VerschiebeOrdner = SHFileOperationA(FileStructur)
End
Function
Sub
Test()
VerschiebeOrdner
"D:\1955\DCIM\100MEDIA"
,
"D:\1954\DCIM\100MEDIA"
End
Sub