1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| Public Sub CréationRepDosSub()
Dim sH As Worksheet
Dim Chemin As String, Commande As String
Dim derligne As Integer, i As Integer
Dim nomDossier As String, Nom As String
Dim fso As Object, Src$, Dest$, Fich$
Const DC As String = "Dossier"
Const PH As String = "Photos"
Const AU As String = "Autre"
Const PJ As String = "PiecesJointes"
Dim Fichier As String
Application.ScreenUpdating = False
Set sH = Worksheets("Feuil1")
ChDrive "c"
Chemin = "c:\users\laurent\desktop\immobilier\Mandats\Clients"
With sH
derligne = .Range("A" & Rows.Count).End(xlUp).Row
For i = 1 To derligne
Nom = .Cells(i, 1) & "_" & .Cells(i, 2) & "\"
nomDossier = Nom & DC
Commande = Environ("comspec") & " /c mkdir " & Chemin & nomDossier
Shell Commande, 0
nomDossier = Nom & DC & "\" & PJ
Commande = Environ("comspec") & " /c mkdir " & Chemin & nomDossier
Shell Commande, 0
nomDossier = Nom & "\" & DC & "\" & PH
Commande = Environ("comspec") & " /c mkdir " & Chemin & nomDossier
Shell Commande, 0
nomDossier = Nom & "\" & DC & "\" & AU
Commande = Environ("comspec") & " /c mkdir " & Chemin & nomDossier
Shell Commande, 0
Next
Set fso = CreateObject("Scripting.FileSystemObject")
Src = "c:\users\laurent\desktop\immobilier\Mandats\"
Dest = "c:\users\laurent\desktop\immobilier\Mandats\Clients_\Dossier\PiecesJointes\"
Fich$ = "plan.xls"
fso.CopyFile Src & Fich, Dest & Fich
End With
Set sH = Nothing
End Sub |
Partager