Use the SHFileOperation api function to do this.
Code:
'********Put this in a module********
Public 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
Public Const FO_MOVE = &H1
Public Const FO_COPY = &H2
Public Const FO_DELETE = &H3
Public Const FO_RENAME = &H4
Public Const FOF_SILENT = &H4
Public Const FOF_RENAMEONCOLLISION = &H8
Public Const FOF_NOCONFIRMATION = &H10
Public Const FOF_SIMPLEPROGRESS = & H100
Public Const FOF_ALLOWUNDO = &H40
Public Declare Function SHFileOperation _
Lib "shell32.dll" Alias "SHFileOperationA" _
(lpFileOp As SHFILEOPSTRUCT) As Long
Put this is a for under a button call Command1.
Code:
Private Sub Command1_Click()
Dim SHF As SHFILEOPSTRUCT
Dim lret As Long
SHF.wFunc = FO_COPY
SHF.hWnd = Me.hWnd
SHF.pFrom = "c:\windows\desktop\tiff\*.*"
SHF.pTo = "c:\windows\desktop\test\"
SHF.fFlags = FOF_SILENT
lret = SHFileOperation(SHF)
'Returns 0 if successful
If lret <> 0 Then
MsgBox "Error"
End If
End Sub
Or you can use FileSystemObject.
Code:
Dim FSO as Object
Private SubForm_Load()
Set FSO = CreateObject("Scripting.FileSystemObject")
'Syntax is object.MoveFolder source, destination
FSO.MoveFolder "c:\myFolder\","c:\backup\myfolder\"
End Sub