UserForm reste en arrière plan

Résolu/Fermé
irongege Messages postés 40847 Date d'inscription jeudi 1 novembre 2007 Statut Modérateur Dernière intervention 29 juin 2023 - 3 avril 2013 à 16:42
irongege Messages postés 40847 Date d'inscription jeudi 1 novembre 2007 Statut Modérateur Dernière intervention 29 juin 2023 - 3 avril 2013 à 18:16
Bonjour,

J'ai un soucis avec un Userform qui ne veut pas se mettre au premier plan lorsque l'on clique sur un bouton pour l'afficher alors que cela marche avec un autre UserForm.

Voici le code pour le 1er userform qui s'affiche bien au 1er plan :

Private Sub validnumbatchf2_Click()
nbrcarac = Len(TextBoxnumbatchf2.Value)
If TextBoxnumbatchf2.Text = "" Or nbrcarac < 9 Or TextBoxdebcyf2.Text = "" Then
 MsgBox "Le numéro du batch ou l'heure saisi sont incorrects"
 Else
validnumbatchf2.Visible = False
matf2.Show ' UserForm qui doit s'afficher
End If
End Sub


le code de l'userform qui s'est bien mis au 1er plan

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 0 Then
MsgBox "Vous ne pouvez pas fermer cette fenêtre.", 16
Cancel = CloseMode = 0
End If
End Sub

Private Sub validmatf2_Click()
   If Application.CountIf(Range("A92:A109"), TextBox1) >= 1 Then
    Range("B85").Value = TextBox1.Text
    Suivi.Labelmatdcyf2.Caption = TextBox1.Text
    Suivi.Show
    Suivi.MultiPage1.Value = 2
    Suivi.debcyf2.Visible = True ' Bouton de procédure d'enregistrement
    TextBox1.Text = ""
    matf2.Hide
    Else: MsgBox "Vous ne disposez pas des droits nécessaires"
End If
End Sub


Lors d'un clic sur le bouton " Suivi.debcyf2 ", il y a enregistrement de données

' -------------------------------enregistrement et impression documents batch F2------------------------------------------------
Private Sub debcyf2_Click()

hrdebcyf2.Caption = Format(Date, "dd.mm.yy")
Workbooks.Open "C:\Suivi_DLC\Archives_" & Range("C33").Value & "\Batch_BL_N°" & Range("B27").Value & "\Docsuivicharge.xls"
[AE114] = Labelnumconfigf2.Caption
[AF115] = TextBoxnumbatchf2.Text
[AH113] = [Y7]
[AE116] = TextBoxdebcyf2.Text
[U9] = [AE116]
[U11] = Labelnumconfigf2.Caption
[S1] = hrdebcyf2.Caption
[D42] = Labelmatdcyf2.Caption
Call nomprenom
[G42] = Labelnomdcyf2.Caption
[K42] = Labelprenomdcyf2.Caption
If [D33] = "X" Then ' broche volante 1
[AH120] = "X"
End If
If [E33] = "X" Then ' broche volante 2
[AH121] = "X"
End If
If [F33] = "X" Then ' broche volante 3
[AH122] = "X"
End If
If [G33] = "X" Then ' broche volante 4
[AH123] = "X"
End If
If [H33] = "X" Then ' broche volante 5
[AH124] = "X"
End If
If [I33] = "X" Then ' broche volante 6
[AH125] = "X"
End If
If [J33] = "X" Then ' broche volante 7
[AH126] = "X"
End If
If [K33] = "X" Then ' broche volante 8
[AH127] = "X"
End If
If [L33] = "X" Then ' broche volante 9
[AH128] = "X"
End If
If [M33] = "X" Then ' broche volante 10
[AH129] = "X"
End If
If [N33] = "X" Then ' broche volante 11
[AH130] = "X"
End If
If [O33] = "X" Then ' broche volante 12
[AH131] = "X"
End If
[AI120] = [D31]
[AI121] = [E31]
[AI122] = [F31]
[AI123] = [G31]
[AI124] = [H31]
[AI125] = [I31]
[AI126] = [J31]
[AI127] = [K31]
[AI128] = [L31]
[AI129] = [M31]
[AI130] = [N31]
[AI131] = [O31]
'Application.Run ("Docsuivicharge.xls!macro5impressionsupervisur")
'Application.Run ("Docsuivicharge.xls!Macro6impressioninfobatchregleur")
ActiveWorkbook.Save
ActiveWindow.Close
'------------------------------------feuille poli ---------------------------------------------
Workbooks.Open "C:\Suivi_DLC\Archives_" & Range("C33").Value & "\Batch_BL_N°" & Range("B27").Value & "\Poli.xls"
[D1] = TextBoxnumbatchf2.Text
'Application.Run ("Poli.xls!impresspoli")
ActiveWorkbook.Save
ActiveWindow.Close
'------------------------------------fin feuille poli -----------------------------------------
[A46] = Labelnumbf2.Caption
[D64] = [A46]
[A48] = Labeltablef2
[D66] = [A48]
blencycledansf2.Visible = True
numblencyclef2.Visible = True
numblencyclef2.Caption = ActiveSheet.Cells(46, 1)
tableencyclef2.Visible = True
numtableencyclef2.Visible = True
numtableencyclef2.Caption = ActiveSheet.Cells(48, 1)
debcyf2.Visible = False
CommandButton5.Visible = True
End Sub


Maintenant survient mon problème, lors du clic sur " CommandButton5 " mon autre userform s'affiche en arrière plan .

Private Sub CommandButton5_Click()
matfincyf2.Show
CommandButton5.Visible = False
End Sub


J'ai essayé en créant une autre userform et le problème reste le même, cette userform reste en arrière plan.

Si quelqu'un avait une idée , ce serait sympa.
Merci


A voir également:

1 réponse

f894009 Messages postés 17185 Date d'inscription dimanche 25 novembre 2007 Statut Membre Dernière intervention 15 avril 2024 1 701
3 avril 2013 à 17:49
Bonjour,

Il faudrait votre fichier sans les donnees des feuilles excel, juste la partie userforms

pour mettre a disposition: click sur le lien suivant https://www.cjoint.com/
Ne pas oublier de copier le lien cree dans votre prochain message.

A+
0
irongege Messages postés 40847 Date d'inscription jeudi 1 novembre 2007 Statut Modérateur Dernière intervention 29 juin 2023 5 054
3 avril 2013 à 18:16
J'ai ajouter :
Suivi.Hide dans la partie de ce code :

Private Sub CommandButton5_Click()
Suivi.Hide
matfincyf2.Show
CommandButton5.Visible = False
End Sub


et aussi ceci à l'activation de cet userform :
Private Sub UserForm_Activate()
    With Me
        .StartUpPosition = 3
        .Width = Application.Width
        .Height = Application.Height
        .Left = 0
        .Top = 0
    End With
End Sub


et elle s'affiche bien au 1er plan.
0