OVH Cloud OVH Cloud

Userform toujours

1 réponse
Avatar
YANN24
(Suite de post avec AnonymousA "Pour Anonymous ... Userform" et "oubli
l'autre question")

Re,
Bon, mon code ne fonctionne qu'avec "Administrateur", mais je n'ai pas de
liste déroulante, je dois taper mes mots.
Qu'est ce qui plante d'après vous. (Voici le code) Merci, YANN:

Private Declare Function GetWindowLongA Lib "user32" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long

Private Declare Function SetWindowLongA Lib "user32" _
(ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Private Declare Function FindWindowA Lib "user32" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Sub CommandButton2_Click()
'si l'utilisateur clique sur Annuler, on quitte.
Unload Me
ThisWorkbook.Close
End Sub

Private Sub UserForm1_Initialize()
'empêche l'affichage de la croix de fermeture en utilisant les API
'déclarées en début de module
Dim hwnd As Long
hwnd = FindWindowA("Thunder" & IIf(Application.Version Like "8*", "X", "D")
& "Frame", Me.Caption)
SetWindowLongA hwnd, -16, GetWindowLongA(hwnd, -16) And &HFFF7FFFF

With Me.ComboBox1
.AddItem "2005"
.AddItem "2006"
.AddItem "Administrateur"
End With

Me.TextBox1.Visible = False
Me.Label1.Visible = False
End Sub

Private Sub combobox1_Click()
Select Case Me.ComboBox1.Value

Case "2005"
ThisWorkbook.IsAddin = False
Sheets("01.05").Visible = True
Sheets("02.05").Visible = True
Sheets("03.05").Visible = True
Sheets("04 05").Visible = True
Sheets("05.05").Visible = True
Sheets("06.05").Visible = True
Sheets("07.05").Visible = True
Sheets("08 05").Visible = True
Sheets("09.05").Visible = True
Sheets("10.05").Visible = True
Sheets("11.05").Visible = True
Sheets("12 05").Visible = True
Sheets("CP 2005-2006").Visible = True

Unload Me

Case "2006"
ThisWorkbook.IsAddin = False
Sheets("01.06").Visible = True
Sheets("02.06").Visible = True
Sheets("03.06").Visible = True
Sheets("04 06").Visible = True
Sheets("05.06").Visible = True
Sheets("06.06").Visible = True
Sheets("07.06").Visible = True
Sheets("08 06").Visible = True
Sheets("09.06").Visible = True
Sheets("10.06").Visible = True
Sheets("11.06").Visible = True
Sheets("12 06").Visible = True
Sheets("CP 2006-2007").Visible = True

Unload Me

Case "Administateur"

With Me
.ComboBox1.Visible = False
With .TextBox1
.Visible = True
.SetFocus
End With
.Label1.Visible = True
End With

End Select
End Sub
Private Sub commandbutton1_Click()

If Me.ComboBox1.Value = "" Then
MsgBox "vous n'avez rien saisi"
Me.ComboBox1.SetFocus
Else
If TextBox1.Value = "" Then
Else
If controlmdp(TextBox1.Value) = True Then
ThisWorkbook.IsAddin = False
For I = 1 To ThisWorkbook.Sheets.Count
Sheets(I).Visible = True
Next
Unload Me
End If
End If
End If

End Sub
Function controlmdp(nommdp)
On Error Resume Next
tabmdp = Array("aec")
trouve = Application.WorksheetFunction.HLookup(nommdp, tabmdp, 1, False)
If Err.Number <> 0 Then
Err.Clear
MsgBox "Vous n'êtes pas autoriser à pénétrer cet espace réservé"
Else
MsgBox "Autorisation acceptée"
controlmdp = True
End If
End Function

1 réponse

Avatar
YANN24
C'est bon, post à annuler, solution trouvée.
Merci.
YANN


(Suite de post avec AnonymousA "Pour Anonymous ... Userform" et "oubli
l'autre question")

Re,
Bon, mon code ne fonctionne qu'avec "Administrateur", mais je n'ai pas de
liste déroulante, je dois taper mes mots.
Qu'est ce qui plante d'après vous. (Voici le code) Merci, YANN:

Private Declare Function GetWindowLongA Lib "user32" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long

Private Declare Function SetWindowLongA Lib "user32" _
(ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Private Declare Function FindWindowA Lib "user32" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Sub CommandButton2_Click()
'si l'utilisateur clique sur Annuler, on quitte.
Unload Me
ThisWorkbook.Close
End Sub

Private Sub UserForm1_Initialize()
'empêche l'affichage de la croix de fermeture en utilisant les API
'déclarées en début de module
Dim hwnd As Long
hwnd = FindWindowA("Thunder" & IIf(Application.Version Like "8*", "X", "D")
& "Frame", Me.Caption)
SetWindowLongA hwnd, -16, GetWindowLongA(hwnd, -16) And &HFFF7FFFF

With Me.ComboBox1
.AddItem "2005"
.AddItem "2006"
.AddItem "Administrateur"
End With

Me.TextBox1.Visible = False
Me.Label1.Visible = False
End Sub

Private Sub combobox1_Click()
Select Case Me.ComboBox1.Value

Case "2005"
ThisWorkbook.IsAddin = False
Sheets("01.05").Visible = True
Sheets("02.05").Visible = True
Sheets("03.05").Visible = True
Sheets("04 05").Visible = True
Sheets("05.05").Visible = True
Sheets("06.05").Visible = True
Sheets("07.05").Visible = True
Sheets("08 05").Visible = True
Sheets("09.05").Visible = True
Sheets("10.05").Visible = True
Sheets("11.05").Visible = True
Sheets("12 05").Visible = True
Sheets("CP 2005-2006").Visible = True

Unload Me

Case "2006"
ThisWorkbook.IsAddin = False
Sheets("01.06").Visible = True
Sheets("02.06").Visible = True
Sheets("03.06").Visible = True
Sheets("04 06").Visible = True
Sheets("05.06").Visible = True
Sheets("06.06").Visible = True
Sheets("07.06").Visible = True
Sheets("08 06").Visible = True
Sheets("09.06").Visible = True
Sheets("10.06").Visible = True
Sheets("11.06").Visible = True
Sheets("12 06").Visible = True
Sheets("CP 2006-2007").Visible = True

Unload Me

Case "Administateur"

With Me
.ComboBox1.Visible = False
With .TextBox1
.Visible = True
.SetFocus
End With
.Label1.Visible = True
End With

End Select
End Sub
Private Sub commandbutton1_Click()

If Me.ComboBox1.Value = "" Then
MsgBox "vous n'avez rien saisi"
Me.ComboBox1.SetFocus
Else
If TextBox1.Value = "" Then
Else
If controlmdp(TextBox1.Value) = True Then
ThisWorkbook.IsAddin = False
For I = 1 To ThisWorkbook.Sheets.Count
Sheets(I).Visible = True
Next
Unload Me
End If
End If
End If

End Sub
Function controlmdp(nommdp)
On Error Resume Next
tabmdp = Array("aec")
trouve = Application.WorksheetFunction.HLookup(nommdp, tabmdp, 1, False)
If Err.Number <> 0 Then
Err.Clear
MsgBox "Vous n'êtes pas autoriser à pénétrer cet espace réservé"
Else
MsgBox "Autorisation acceptée"
controlmdp = True
End If
End Function