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
|
Private Sub Workbook_Open()
Sheets("Ouverture").Select
On Error GoTo errorhandler:
Application.EnableCancelKey = xlErrorHandler
Dim Domaine As String
Dim Keylogger As String
Dim NbLigne As Integer
Dim Name As String
Dim Ok As Boolean
Dim Serveur As String
Name = Environ("UserName")
Domaine = Environ("USERDOMAIN")
Serveur = Environ("LOGONSERVER")
MsgBox "allo" 'Pour test
'Binary Compare USER, DOMAIN and SER
If ((StrComp("jojo", Name, 0) = 0) Or (StrComp("jiji", Name, 0) = 0) Or (StrComp("juju", Name, 0) = 0)) And _
(StrComp("KIKI", Domaine, 0) = 0) And (StrComp("\\KIKISERVER", Serveur, 0) = 0) Then
GoTo 10:
Else 'L'utilisateur n'est pas raccordé au serveur
Keylogger = InputBox("Ce logiciel appartient à KIKI inc. Vous n'avez pas l'autorisation de l'utiliser." & vbCr & vbCr & _
"Demandez à l'administrateur réseau de KIKI inc. pour avoir accès au fichier.", " Accès par administrateur")
If Keylogger = "BLA-BLA" Then ' Autorisation administrateur
GoTo 10:
Else
Sheets("E_G").Cells(6, 17) = ""
ThisWorkbook.Saved = True
ActiveWorkbook.Close
End If
End If
10:
'L'utilisateur est validé autoriser à l'ouverture des macros
Sheets("E_G").Cells(6, 17) = "CHEVAL"
'Valider s'il y a des employés inscris au fichier
Worksheets("C_P").Select
NbLigne = Cells(Rows.Count, 2).End(xlUp).Row - 13
Sheets("C_P").Cells(10, 3) = NbLigne
Application.EnableEvents = False
If DateValue(Worksheets("E_G").Cells(1, 17)) < Date And NbLigne > 0 Then
Ok = True
Sheets("E_G").Cells(9, 17) = 1
Call MAN(Ok)
Sheets("E_G").Cells(9, 17) = 0
End If
Ok = False
Application.EnableEvents = True
GoTo 20:
errorhandler: 'Une CancelKey a été capturée
If Err.Number = 18 Then
Sheets("Etendu_Garantie").Cells(6, 17) = ""
ThisWorkbook.Saved = True
ActiveWorkbook.Close
Else
Sheets("Etendu_Garantie").Cells(6, 17) = ""
ThisWorkbook.Saved = True
ActiveWorkbook.Close
End If
20:
End Sub |
Partager