Private Declare Function MkDir Lib "imagehlp.dll" _ Alias "MakeSureDirectoryPathExists" _ (ByVal lpPath As String) As LongCette déclaration, à mettre dans la partie "Déclarations" de ta page de code, permet de faire appel à une fonction nommée à l'origine MakeSureDirectoryPathExists et que nous utiliserons sous le nom de MkDir.
Call MkDir("C:\mon chemin\a\b\c")
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionSub Dossier() i = 3 Do While Cells(i, 5) <> "" MkDir "c:\chemin" & Cells(i, 5) i = i + 1 ' <----- Ici Loop End Sub
Public Function IsFolderExists(ByRef FolderName As String) As Boolean ' Renvoie True si le répertoire existe bien On Local Error GoTo Erreur If Len(FolderName) = 0 Then Exit Function If Len(Dir(FolderName, vbDirectory)) <> 0 Then IsFolderExists = True Exit Function Erreur: IsFolderExists = False End Function
If Not IsFolderExists("c:\mon répertoire") Then MkDir "c:\mon répertoire"
Public Function IsFolderExists(ByRef FolderName As String) As Boolean ' Renvoie True si le répertoire existe bien On Local Error GoTo Erreur If Len(FolderName) = 0 Then Exit Function If Len(Dir(FolderName, vbDirectory)) <> 0 Then IsFolderExists = True Exit Function Erreur: IsFolderExists = False End Function Sub Dossier() i = 3 Do While Cells(i, 5) <> "" If Not IsFolderExists "c:\Users\Guillaume\Documents\PhotoFilm" & Cells(i, 5) Then MkDir "c:\Users\Guillaume\Documents\PhotoFilm"& Cells(i, 5) i = i + 1 Loop End Sub