1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
| Option Explicit
Option Base 1
Dim Utilisateur As String, TbNom, x As Integer, Sh As Worksheet, TbMdp
Dim LeCode As String, Mdp As String
Private Sub Workbook_Open()
Application.Caption = "PCE Devxl & Consulting"
ActiveWindow.DisplayHorizontalScrollBar = False
ActiveWindow.DisplayVerticalScrollBar = False
Application.DisplayFormulaBar = False
Application.CommandBars("Control Toolbox").Controls(1).Enabled = False
Application.CommandBars("Visual Basic").Enabled = False
Application.DisplayAlerts = False
Sheets("Acceuil").Activate
Application.DisplayAlerts = False
x = 0
For Each Sh In Worksheets
If Sh.Name <> "Acceuil" Then
x = x + 1
Range("A" & x) = Sh.Name
End If
Next Sh
TbNom = Array(Ut1, Ut2, Ut3)
TbMdp = Array(Mdp1, Mdp2, Mdp3)
Utilisateur = InputBox("Veuillez entrer Votre identifiant", "LOGIN")
For x = 1 To UBound(TbNom)
If TbNom(x) = Utilisateur Then
LeCode = TbMdp(x)
Exit For
ElseIf x = 4 Then
MsgBox "Vous ne pouvez pas utiliser les liens"
Exit Sub
End If
Next x
For x = 1 To 4
If x = 4 Then Exit For
Mdp = InputBox("Veuillez entrer Votre mot de passe", "CODE SECRET")
If Mdp <> LeCode Then
MsgBox "le code ne correspond pas à l'utilisateur" & Chr(10) & "ATTENTION !, vous avez 3 essais"
Else
If Utilisateur = Ut1 Then
ActiveSheet.Hyperlinks.Add Anchor:=Range("A1"), Address:="", SubAddress:= _
"Feuil2!A1", TextToDisplay:=Sheets("Feuil2").Name
ActiveSheet.Hyperlinks.Add Anchor:=Range("A3"), Address:="", SubAddress:= _
"Feuil4!A1", TextToDisplay:=Sheets("Feuil4").Name
ElseIf Utilisateur = Ut2 Then
ActiveSheet.Hyperlinks.Add Anchor:=Range("A2"), Address:="", SubAddress:= _
"Feuil3!A1", TextToDisplay:=Sheets("Feuil3").Name
ActiveSheet.Hyperlinks.Add Anchor:=Range("A4"), Address:="", SubAddress:= _
"Feuil5!A1", TextToDisplay:=Sheets("Feuil5").Name
ElseIf Utilisateur = Ut3 Then
ActiveSheet.Hyperlinks.Add Anchor:=Range("A1"), Address:="", SubAddress:= _
"Feuil2!A1", TextToDisplay:=Sheets("Feuil2").Name
ActiveSheet.Hyperlinks.Add Anchor:=Range("A5"), Address:="", SubAddress:= _
"Feuil6!A1", TextToDisplay:=Sheets("Feuil6").Name
End If
Exit For
End If
Next x
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If SaveAsUI = True Then Cancel = True
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Not flag Then Cancel = True
Dim dl As Integer
With Sheets("Acceuil")
dl = .Range("A" & .Rows.Count).End(xlUp).Row
.Range("A1:A" & dl).Clear
End With
For Each Sh In Worksheets
If Sh.Name <> "Acceuil" Then
Sh.Visible = False
End If
Next Sh
End Sub |
Partager