Bonjour Johana, Léa, le Forum
Voici une méthode un peu plus approndie pour gérer les erreurs possibles car j'ai eu à la mettre en place au bureau :
Const TheMainPath As String = 'C:\\Program Files\\My Program\\'
Const TheArchivePath As String = 'C:\\Program Files\\My Program\\My Archive\\'
Sub TestMkDirMultiLevel1()
On Error GoTo NextStep
MkDir TheMainPath
NextStep:
TestMkDirMultiLevel2
End Sub
Sub TestMkDirMultiLevel2()
On Error GoTo Sortie
MkDir TheArchivePath
Exit Sub
Sortie:
If Err = 75 Then
MsgBox 'Le Chemin ' & TheArchivePath & ' existe déjà'
Else
MsgBox 'Une Erreur non gérée s'est Produite : ' & Err.Number & ' ' & Err.Description
End If
End Sub
Sinon en plus élaboré j'avais essayé ceci aussi (attention Split non compatible Excel 97) :
Sub CheckingMakingDir()
Dim TheFullPath As String
Dim TheSplitedPath As Variant
Dim i As Byte, NbRep As Byte
Dim ThePath As String
TheFullPath = Range('Ch_Fichier')
TheSplitedPath = Split(TheFullPath, '\\')
NbRep = UBound(TheSplitedPath)
For i = 0 To NbRep
ThePath = ThePath & TheSplitedPath(i) & '\\'
MakingDir ThePath
Next
End Sub
Sub MakingDir(ThePath As String)
On Error GoTo TheEnd
MkDir ThePath
TheEnd:
End Sub
Bonne Soirée
@+Thierry