Public Function FileFolderExists(strFullPath As String) As Boolean
On Error GoTo EarlyExit
If Not Dir(strFullPath, vbDirectory) = vbNullString Then FileFolderExists = True
EarlyExit:
On Error GoTo 0
End Function
Public Sub TestFolderExistence()
Range("date").Select
Date1 = Range("date").Value
Annee = Year(Date1)
Mois = Month(Date1)
'Vérifie l'existence du fichier année
If Not FileFolderExists("U:\Tasset\Essai_3\Interfaces\Création" + "\" + Format(Annee, "####")) Then
MkDir ("U:\Tasset\Essai_3\Interfaces\Création" + "\" + Format(Annee, "####"))
End If
'Vérifie l'existence du fichier mois
If Not FileFolderExists("U:\Tasset\Essai_3\Interfaces\Création" + "\" + _
Format(Annee, "####") + "\" + Format(Mois, "00")) Then
MkDir ("U:\Tasset\Essai_3\Interfaces\Création" + "\" + Format(Annee, "####") + "\" + Format(Mois, "00"))
End If
'Vérifie l'existence du classeur
'If Not FileFolderExists("U:\Tasset\Essai_3\Interfaces\Création\2008\05\just a try.xls") Then
'Workbooks.Add
'ActiveWorkbook.SaveAs Filename:="U:\Tasset\Essai_3\Interfaces\Création\2008\05\everybreathyoutake.xls"
'End If
End Sub
Public Sub TestFileExistence()
Dim buffer As String
Range("date").Select
Date1 = Range("date").Value
Annee = Year(Date1)
Mois = Month(Date1)
buffer = "U:\Tasset\Essai_3\Interfaces\Création" + "\" + _
Format(Annee, "####") + "\" + Format(Mois, "00") + "\" + Sheets(1).Range("mix").Value
If Not FileFolderExists(buffer) Then
Workbooks.Add
ActiveWorkbook.SaveAs Filename:=("U:\Tasset\Essai_3\Interfaces\Création" + "\" + _
Format(Annee, "####") + "\" + Format(Mois, "00") + "\" + Sheets(1).Range("mix").Value)
End If
End Sub