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 43 44 45 46 47 48 49 50 51 52
| Option Compare Database
Option Explicit
Sub Verifier_Presence_Sous_Dossier()
Dim Pth As String
Dim i As Integer
Dim strSql As String
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim fs As FileSystemObject
Dim mySource As Object
Dim Folder As Variant
Dim fso As Object
Set dbs = CurrentDb
Dim Root1 As String, Root2 As String, Root3 As String
Dim NewName As String
Dim varFldrsRoot1 As Variant
Set dbs = CurrentDb
strSql = "SELECT DEC.Matr, DEC.NomName, DEC.NomNameMatr, DEC.NomNameMatrk, DEC.Languagecode FROM [DEC] WHERE (((DEC.Languagecode)=1) AND ((DEC.[Matr])=3478 Or (DEC.[Matr])=105185 Or (DEC.[Matr])=5363));"
Set rst = dbs.OpenRecordset(strSql, dbOpenSnapshot, dbFailOnError)
Pth = "F:\Pers\" 'Path to the top folder with trailing slash
Root1 = Pth & rst!NomName
Root2 = Root1 & "\" & "J. Fin du contrat"
'Root3 = Root1 & "B. Promotions"
If Len(Dir(Root1, vbDirectory)) = 0 Then
MkDir Root1
End If
If Len(Dir(Root2, vbDirectory)) = 0 Then
MkDir Root2
End If
varFldrsRoot1 = Split("1. Dispo retraite anticipée et rappel en service,2. Pension,3. demission,4. Fiche B2,5. Autre", ",")
For i = 0 To UBound(varFldrsRoot1)
If Len(Dir(Root2 & "\" & varFldrsRoot1(i), vbDirectory)) = 0 Then
MkDir Root2 & "\" & varFldrsRoot1(i)
End If
Next i
End Sub |
Partager