(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
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
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
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
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
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
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
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
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