Ver Mensaje Individual
  #2 (permalink)  
Antiguo 06/05/2008, 09:01
Avatar de David
David
Moderador
 
Fecha de Ingreso: abril-2005
Ubicación: In this planet
Mensajes: 15.720
Antigüedad: 19 años, 1 mes
Puntos: 839
Re: copiar carpeta por fecha

Prueba con este código:
Código:
 
Sub CopyBackup(ByVal Path As String, ByVal Destination As String)
On Error Resume Next
Dim SF As Scripting.File
Dim FSO As Object
Set FSO = New Scripting.FileSystemObject
Dim FolderName As String
FolderName = Dir(Path & "*.*", vbDirectory)
Do
    If FolderName = "" Then Exit Do
    If GetAttr(Path & FolderName) = vbDirectory And FolderName <> "." And FolderName <> ".." Then
        If Format(FSO.GetFolder(Path & FolderName).DateCreated, "dd/mm/yyyy") = Format(Now - 1, "dd/mm/yyyy") Then
            FSO.CopyFolder Path & FolderName, Destination
            Set SF = Nothing
            Set FSO = Nothing
            Exit Sub
        End If
    End If
    FolderName = Dir
Loop
End Sub
Esta vez, hice una adaptación del código que había colocado para eliminar las carpetas anteriores a 4 días...
Si te sirve, me avisas.
Saludos

P.S.: Para llamarlo colocas:
Código:
 
CopyBackup "C:\WINDOWS\carpeta\Pv Traslados\", "c:\Pv Traslados\"
__________________
Por favor, antes de preguntar, revisa la Guía para realizar preguntas.

Última edición por David; 06/05/2008 a las 09:13 Razón: Editar código, liberar variables