Bon, voilà ce que j'ai essayé, bien entendu çà ne marche pas
Option Explicit
Private Sub Workbook_Open()
Dim ws As Worksheet
Application.ScreenUpdating = False
With ThisWorkbook
For Each ws In .Worksheets
ws.Visible = xlSheetVisible
Next ws
.Worksheets(5).Visible = 2
End With
If Worksheets("Enquête").Range("J2") = "N° XXX" Then
MsgBox "ATTENTION FICHIER ORIGINAL" _
& vbNewLine & vbNewLine _
& "vous devez être un utilisateur autorisé, " _
& "pour pouvoir le modifier. ", vbOKOnly + vbExclamation, "Enquête pale principale 365 N4 Original"
End If
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim Utilisateur As String
Utilisateur = InputBoxDK("Indiquez votre nom d'utilisateur !", "Authentification utilisateur")
Select Case Utilisateur
Case "CN13723", "Nom2", "Nom3", "Nom4" '<--- les noms pour lesquels l'enregistrement est autorisé
Case Else
MsgBox "Vous n'êtes pas autorisé à enregistrer les modifications que vous avez apporté ! " _
& vbNewLine & vbNewLine _
& "Ce fichier et EXCEL vont être fermer. ", vbOKOnly + vbCritical, "Fermeture d'enquête pale principale 365 N4"
Cancel = True
Windows.Application.Quit
End Select
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim i As Long
Application.ScreenUpdating = False
With ThisWorkbook
.Worksheets(5).Visible = -1
For i = 2 To .Worksheets.Count
.Worksheets(i).Visible = 2
Next i
End With
End Sub