XL 2016 Encore besoin d'aide sur l'enregistrement d'un fichier

christ77000

XLDnaute Occasionnel
Bonsoir à tous.
Je viens de bricoler ce code et le therme est le bon car il ne fonctionne pas et je ne vois pas ou est l'erreur. quoi que je fasse il me dit "le fichier existe déjà...

VB:
Sub Enregistrer_sous()
Dim Path As String, Nom As String



If Dir(Path & Nom) <> "" Then
       MsgBox "Le fichier existe déjà !" & Chr(10) & "Vous pourrez le créer en " & Range("P9").Value, vbInformation
    Else
    
Application.DisplayAlerts = False
Path = Range("C40").Value
Nom = Range("O9").Value & ".xlsm"
ThisWorkbook.SaveAs Path & Nom
Call Creation_Dossiers
Call RAZ_du_fichier1
ActiveWorkbook.Save
End If
 
End Sub
 

christ77000

XLDnaute Occasionnel
merci pour ta réponse, je débute dans le vba donc pas encore tout bien compris.
j'ais modifier comme ca, mais pas beaucoup mieux.

VB:
Sub Enregistrer_sous2()

Dim Path As String, Nom As String

Application.DisplayAlerts = False
Path = Range("C40").Value
Nom = Range("O9").Value & ".xlsm"

If Dir(Path & Nom) <> "" Then
       MsgBox "Le fichier existe déjà !" & Chr(10) & "Vous pourrez le créer en " & Range("P9").Value, vbInformation
    Else
   

ThisWorkbook.SaveAs Path & Nom
'Call Creation_Dossiers
'Call RAZ_du_fichier1
ActiveWorkbook.Save
End If

End Sub
 

Discussions similaires

Réponses
2
Affichages
203

Statistiques des forums

Discussions
312 111
Messages
2 085 399
Membres
102 882
dernier inscrit
Sultan94