Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

userform et croix rouge

6 réponses
Avatar
Nyck0las
Bonjour,

Comment puis-je faire pour utiliser la petite croix rouge en haut =E0
droite d'un userform ?
Je voudrais lui dire de quitter ma macro si jamais on clique dessus.

merci

6 réponses

Avatar
Daniel.C
Bonjour.
Utilise l'évènement :
UserForm_Terminate
Cordialement.
Daniel
"Nyck0las" a écrit dans le message de news:

Bonjour,

Comment puis-je faire pour utiliser la petite croix rouge en haut à
droite d'un userform ?
Je voudrais lui dire de quitter ma macro si jamais on clique dessus.

merci
Avatar
Nyck0las
çà marche pas :-(

la macro s'arrete alors que je n'ai pas cliqué sur fermer ...
Avatar
Daniel.C
Pas compris. Poste ton code.
Daniel
"Nyck0las" a écrit dans le message de news:

çà marche pas :-(

la macro s'arrete alors que je n'ai pas cliqué sur fermer ...
Avatar
Nyck0las
voici un des userform que j'utilise :

Private Sub userForm_Initialize()

Rd_OD = True

Pourcent = Pct
Pourcent.Locked = True

Seuil = SCpl
Seuil.Locked = True

With Spin_P
.min = 0
.Max = 100
.SmallChange = 1
End With

With Spin_S
.min = 0
.Max = 100
.SmallChange = 1
End With

End Sub

Private Sub Spin_P_Change()
Pourcent = Spin_P.Value
End Sub

Private Sub Spin_S_Change()
Seuil = Spin_S.Value
End Sub

Private Sub Pourcent_Change()
Dim NewVal As Integer
NewVal = val(Pourcent.Text)
If NewVal >= Spin_P.min And NewVal <= Spin_P.Max Then Spin_P.Value
= NewVal
End Sub

Private Sub Seuil_Change()
Dim NewVal As Integer
NewVal = val(Seuil.Text)
If NewVal >= Spin_S.min And NewVal <= Spin_S.Max Then Spin_S.Value
= NewVal
End Sub

Private Sub OK_Click()
Unload ChxParam
Pct = val(Pourcent.Text)
SCpl = val(Seuil.Text)
If Rd_OD = True Then
Mode_Reduc = "On demand"
ElseIf Rd_A = True Then
Mode_Reduc = "Auto"
ElseIf Rd_N = True Then
Mode_Reduc = "None"
End If
End Sub


Ce que je souhaiterais, c'est que lorsque je clique sur la petite
croix rouge de l'userform, je quitte la macro toute entière.
Ce qui reviendrait à un truc du type :

Private Sub Croix_Rouge_Click()
End
End Sub

or si je mets un truc de ce type :

Private Sub UserForm_Terminate()
end
End Sub

même quand je clique sur ok, tout s'arrete
Avatar
Daniel.C
Si ton userform s'appelle ChxParam,
tu écris :
Private Sub userForm_Initialize()
teste=0
...

Private Sub Croix_Rouge_Click()
teste=1
End Sub
Private Sub OK_Click()
if teste=1 then
end
else
....
end if
Daniel
"Nyck0las" a écrit dans le message de news:

voici un des userform que j'utilise :

Private Sub userForm_Initialize()

Rd_OD = True

Pourcent = Pct
Pourcent.Locked = True

Seuil = SCpl
Seuil.Locked = True

With Spin_P
.min = 0
.Max = 100
.SmallChange = 1
End With

With Spin_S
.min = 0
.Max = 100
.SmallChange = 1
End With

End Sub

Private Sub Spin_P_Change()
Pourcent = Spin_P.Value
End Sub

Private Sub Spin_S_Change()
Seuil = Spin_S.Value
End Sub

Private Sub Pourcent_Change()
Dim NewVal As Integer
NewVal = val(Pourcent.Text)
If NewVal >= Spin_P.min And NewVal <= Spin_P.Max Then Spin_P.Value
= NewVal
End Sub

Private Sub Seuil_Change()
Dim NewVal As Integer
NewVal = val(Seuil.Text)
If NewVal >= Spin_S.min And NewVal <= Spin_S.Max Then Spin_S.Value
= NewVal
End Sub

Private Sub OK_Click()
Unload ChxParam
Pct = val(Pourcent.Text)
SCpl = val(Seuil.Text)
If Rd_OD = True Then
Mode_Reduc = "On demand"
ElseIf Rd_A = True Then
Mode_Reduc = "Auto"
ElseIf Rd_N = True Then
Mode_Reduc = "None"
End If
End Sub


Ce que je souhaiterais, c'est que lorsque je clique sur la petite
croix rouge de l'userform, je quitte la macro toute entière.
Ce qui reviendrait à un truc du type :

Private Sub Croix_Rouge_Click()
End
End Sub

or si je mets un truc de ce type :

Private Sub UserForm_Terminate()
end
End Sub

même quand je clique sur ok, tout s'arrete
Avatar
Daniel.C
Faut affiner.
Dans un module :
Public teste
Private Sub userForm_Initialize()
teste=0
...
Private Sub Userform_Terminate()
if teste = 0 then end
End Sub
Private Sub OK_Click()
teste = 1
...
Daniel
"Daniel.C" a écrit dans le message de news:
%
Si ton userform s'appelle ChxParam,
tu écris :
Private Sub userForm_Initialize()
teste=0
...

Private Sub Croix_Rouge_Click()
teste=1
End Sub
Private Sub OK_Click()
if teste=1 then
end
else
....
end if
Daniel
"Nyck0las" a écrit dans le message de news:

voici un des userform que j'utilise :

Private Sub userForm_Initialize()

Rd_OD = True

Pourcent = Pct
Pourcent.Locked = True

Seuil = SCpl
Seuil.Locked = True

With Spin_P
.min = 0
.Max = 100
.SmallChange = 1
End With

With Spin_S
.min = 0
.Max = 100
.SmallChange = 1
End With

End Sub

Private Sub Spin_P_Change()
Pourcent = Spin_P.Value
End Sub

Private Sub Spin_S_Change()
Seuil = Spin_S.Value
End Sub

Private Sub Pourcent_Change()
Dim NewVal As Integer
NewVal = val(Pourcent.Text)
If NewVal >= Spin_P.min And NewVal <= Spin_P.Max Then Spin_P.Value
= NewVal
End Sub

Private Sub Seuil_Change()
Dim NewVal As Integer
NewVal = val(Seuil.Text)
If NewVal >= Spin_S.min And NewVal <= Spin_S.Max Then Spin_S.Value
= NewVal
End Sub

Private Sub OK_Click()
Unload ChxParam
Pct = val(Pourcent.Text)
SCpl = val(Seuil.Text)
If Rd_OD = True Then
Mode_Reduc = "On demand"
ElseIf Rd_A = True Then
Mode_Reduc = "Auto"
ElseIf Rd_N = True Then
Mode_Reduc = "None"
End If
End Sub


Ce que je souhaiterais, c'est que lorsque je clique sur la petite
croix rouge de l'userform, je quitte la macro toute entière.
Ce qui reviendrait à un truc du type :

Private Sub Croix_Rouge_Click()
End
End Sub

or si je mets un truc de ce type :

Private Sub UserForm_Terminate()
end
End Sub

même quand je clique sur ok, tout s'arrete