Private Declare Function SHCreateDirectoryEx Lib "Shell32.dll" Alias "SHCreateDirectoryExA" _
(ByVal hwnd As Long, ByVal pszPath As String, ByVal lngsec As Long) As Long
Public i As Double
Public NomSource, NomRep1, RepNomDest, ext As String
Private Sub CreationDossier(sNomRep As String)
'issu d'un code de KiKi29 de http://www.excel-downloads.com/forum/110203-cr-er-dossier-enregistrer-dedans.html
'ChDrive "D"
'Stop
SHCreateDirectoryEx 0&, sNomRep, 0&
End Sub
Sub Lance_sauvegarde_Vers_C_DVD()
'
' Macro2 Macro
' Macro enregistrée le 18/01/2010 par MJ
'
Dim Rep As String
'Stop
'recherche=ligne() qui oit être mis en face de chaque DVD
'Range("A1").Select
' Cells.Find(What:="Total Général", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=2, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
'Cells.Find(What:="LIGNE", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=2, SearchOrder:=1, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
ncact = ActiveCell.Column
nldeb = ActiveCell.Value
Selection.End(xlDown).Select
nlfin = ActiveCell.Value
'NomRep1 = Cells(1, ncact - 2) & ":\" & Cells(nldeb, ncact - 2) & "\"
NomRep1 = Cells(1, 1) & ":\" & Cells(nldeb, ncact - 1) & "\"
'GoTo suite
'Création nom dossier
For i = nldeb + 1 To nlfin
Rep = NomRep1 & Cells(i, 1) & "\" & Mid(Cells(i, 2), 3, Len(Cells(i, 2)) - 2)
CreationDossier Rep
Next
'Stop
suite:
'Stop
'A amléliorer si il y a
For i = nldeb + 1 To nlfin
copy_fich
'On Error Resume Next
'If Cells(i, 4) > 0 Then ext = Cells(2, 4): copy_fich
'If Cells(i, 5) > 0 Then ext = Cells(2, 5): copy_fich
'If Cells(i, 6) > 0 Then ext = Cells(2, 6): copy_fich
Next
'Stop
End Sub
Sub copy_fich()
'Stop
'On Error Resume Next
On Error GoTo suite
NomSource = Cells(i, 2) & "\" & Cells(i, 3) ' & "." & ext
RepNomDest = NomRep1 & Cells(i, 1) & Mid(Cells(i, 2), 3, Len(Cells(i, 2)) - 2) & "\" & Cells(i, 3) '& "." & ext
FileCopy NomSource, RepNomDest
GoTo suite2
suite:
Cells(i, 2).Font.Bold = True
Cells(i, 3).Font.Bold = True
suite2:
End Sub
Sub copy_fich_racine()
' Stop
'NomSource = Cells(i, 2) & "\" & Cells(i, 3) ' & "." & ext
'RepNomDest = NomRep1 & Cells(i, 1) & Mid(Cells(i, 2), 3, Len(Cells(i, 2)) - 2) & "\" & Cells(i, 3) & "." & ext
'FileCopy NomSource, RepNomDest
'Stop Attention choisir par inputbox par exemple (ou faire des options buttons sur la feuille)
NomSource = Cells(i, 2) & "\" & Cells(i, 3) ' & "." & ext
'Copie avec la structure des dossiers
'RepNomDest = NomRep1 & Cells(i, 1) & Mid(Cells(i, 2), 3, Len(Cells(i, 2)) - 2) & "\" & Cells(i, 3) & "." & ext
'Faire un RepNomDest sans nom de dossier (pour les fichierss multimédia (atention aux doublons))
RepNomDest = NomRep1 & "\" & Cells(i, 3) '& "." & ext
FileCopy NomSource, RepNomDest
End Sub