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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
Option Explicit
Private Sub Workbook_Open()
Dim poingdeoart As String
Dim bankfichier As String
Dim xxmax As Integer
Dim xxincr As Integer
Dim icifiadepla() As String
Dim icidosvis() As String
Dim icideou As String
Dim poingdeoartf As String
Dim Sup
'gestion du tableau
xxmax = 2 'nombre de fichier a installer
poingdeoart = "C:\" 'point de depart
poingdeoartf = poingdeoart
ReDim icifiadepla(xxmax)
ReDim icidosvis(xxmax)
'liste des fichiers a installer
icifiadepla(2) = "coco.txt"
icidosvis(2) = "temp"
icifiadepla(1) = "tata.txt"
icidosvis(1) = "macros"
'installation des fichiers
For xxincr = 1 To xxmax
If jeregarde(icifiadepla(xxincr)) = 1 Then'voir si le fichier source est a la bonne place
poingdeoart = poingdeoartf
Call jecopie(poingdeoart, icidosvis(xxincr), (poingdeoart & icifiadepla(xxincr)), icifiadepla(xxincr))
MsgBox "IcI"
Else
MsgBox "this files is not in c:\ =>" & icifiadepla(xxincr)
Exit Sub
End If
Next xxincr
'pour fermer le programme
Sup = MsgBox("do you want to leave", vbYesNoCancel)
If Sup = vbYes Then
ActiveWorkbook.Close
End If
End Sub
Function jecopie(stRep1 As String, dosvis As String, deou As String, fiadepla As String)
Dim stRep
Dim oFSO, oFld
Dim iTemp As Integer
Dim aa As Integer
Dim conca As String
'gestion des variable et objet
aa = 0
Set oFSO = CreateObject("Scripting.FileSystemObject")
stRep = stRep1
If oFSO.FolderExists(stRep) Then
If Not IsNull(oFld) Then
For Each oFld In oFSO.GetFolder(stRep).SubFolders
On Error Resume Next
If LCase(Right(oFld.Name, (Len(oFld) - Len(stRep)))) = LCase(dosvis) Then
conca = oFld & "\" & fiadepla
'On Error Resume Next
iTemp = GetAttr(conca)
Select Case err.Number
Case Is <> 0
FileCopy deou, conca
End Select
Else
stRep1 = oFld
Call jecopie(stRep1, dosvis, deou, fiadepla)
End If
Next
End If
End If
End Function
Function jeregarde(lefichier As String) As Integer
Dim concajr As String
Dim iTemp As Integer
jeregarde = 0
concajr = "C:\" & lefichier
On Error Resume Next
iTemp = GetAttr(concajr)
Select Case err.Number
Case Is = 0
jeregarde = 1
End Select
End Function |
Partager