'Option Explicit
Private Sub Workbook_Open()
Feuil1.ScrollArea = "A1:N32"
Feuil5.ScrollArea = "A1:H15"
Feuil6.ScrollArea = "A1:Q29"
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
With Sheets("Echéancier")
Nom = .Range("B2")
PCE = .Range("G6")
End With
'NNI des agents
'Marignane
Matthieu = "b90570"
Yacine = "J03455"
Sophie = "d41254"
Maxence = "J33056"
Remi = "f02756"
Camille = "c60772"
Cindy = "cm0d924n"
Sarah = "ss0c0can"
Priscilla = "d91472"
Zoe = "F90572"
Elodie = "d04673"
Virginie = "VR023B1N"
Daniel = "h86540"
Nathalie = "b22929"
Alexandre = "i62338"
Stephane = "a06745"
Florent = "C65470"
'Nimes
Fabienne = "f74844"
Claudia = "j88653"
Magali = "J37249"
'Recherche de l'utilisateur qui a ouvert la session
utilisateur = Environ("username")
Select Case utilisateur
Case Matthieu, Yacine, Sophie, Maxence, Remi, Camille, Cindy, Sarah, Priscilla, Zoe, Elodie, Virginie, Daniel, Nathalie, Alexandre, Stephane, Florent
chemin = "Q:\AAGP2\PDD GAZ\PDD\Dossiers PDD\En cours" & "\" & Nom & " " & PCE
fichier = "Q:\AAGP2\PDD GAZ\PDD\Dossiers PDD\En cours" & "\" & Nom & " " & PCE & "\" & Nom & " " & "Gaz-Perd.xlsm"
Case Fabienne, Claudia, Magali
chemin = "Q:\AAG\DOSSIERS NUMERIQUES PDD" & "\" & Nom & " " & PCE
fichier = "Q:\AAG\DOSSIERS NUMERIQUES PDD" & "\" & Nom & " " & PCE & "\" & Nom & " " & "Gaz-Perd.xlsm"
End Select
If Nom = "" Or PCE = "" Then
'MsgBox "Pour enregistrer le classeur d'un client, veuillez remplir les champs Nom Prénom et PCE et créer le dossier client.", vbInformation, "Information"
Exit Sub
End If
If Dir(chemin, vbDirectory) = "" Then
MsgBox "Le dossier numérique de " & Nom & " " & PCE & " n'a pas été créé. Veuillez le créer puis recommencer.", vbCritical, "Attention"
Exit Sub
End If
If Dir(fichier, vbNormal) <> "" Then
Reponse = MsgBox("Le classeur de " & Nom & " existe déjà." & vbLf & vbLf & _
"Confirmez-vous son remplacement ?", vbYesNoCancel, "Attention")
If Reponse = vbNo Then
ThisWorkbook.Close Savechanges:=False
Exit Sub
End If
If Reponse = vbCancel Then
Cancel = True
Else
Sheets("Echéancier").Range("K4").Value = Format(Now, "dddd dd mmmm yyyy / h:mm")
ThisWorkbook.Close Savechanges:=True
Exit Sub
End If
End If
'ChDir chemin
'ActiveWorkbook.SaveAs Filename:=fichier, FileFormat:=xlOpenXMLWorkbookMacroEnabled, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False
'Sheets("Echéancier").Range("K4").Value = Format(Now, "dddd dd mmmm yyyy / h:mm")
End Sub