Bonjour,

J'ai un userfom qui est mis à jour seulement à son premier lancement, malgré l'utilisation de activate. L'exécution se bloque sur l'affichage vide de l'userform malgré que les champs soit renseigné de bonne valeur (espion). Il n'y a pas d'erreur d'exécution. Une pause de la macro s'effectue sur la ligne de lancement de l'userform (en rouge dans mon code). Seul l'arrêt de la macro me redonne la main sur Excel.

Environnement
1 userform (accueil) avec 2 boutons lançant chacun de la même manière 2 userform (ajout et commande). Des routines de masquages et d'affichage de la feuille sont mise en place. Le lancement de userfom1 (Ajout) fonctionne correctement, mais le second (Commande) n'est traité qu'à la première exécution.

Pour information, l'application est développé sous Excel2010 mais doit fonctionner sous Excel2007.

Quel peut-être le problème ?

Userform Accueil
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
Private Sub BP_AjoutNom_Click()
    Application.ScreenUpdating = True
    Call ShowExcel
    Sheets("Liste").Select
    Me.Hide
    Load UF_Ajout
    UF_Ajout.Show
End Sub

Private Sub BP_Modif_Commande_Click()
    Application.ScreenUpdating = True
    Call ShowExcel
    Sheets("commande").Select
    Me.Hide
    Load UF_Commande
'ajout suite au bug
    If Me.BP_Modif_Commande.Tag = "true" Then
        'Me.BP_Modif_Commande.Tag = "false"
        'Stop
        MsgBox ("Suite ? un bug en cour de r?solution," + Chr(10) + Chr(13) + "merci de relancer l'application")
        Unload UF_Commande
        Me.Show
    Else
        Me.BP_Modif_Commande.Tag = "true"
        UF_Commande.Show
    End If
Userform Nom (fonctionnel)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
Private Sub UserForm_Initialize()
    Me.FNoFiche.Visible = False
    Me.ERREUR.Visible = False
    Me.BP_Ajout.Caption = "Ajout"
    Me.BP_Recherche.Caption = "Recherche ..."
    Me.CB2.Visible = False
    Me.CB2 = False
    Me.CB2.Tag = "false"
    Me.L1.Visible = False
    Sheets("Liste").Select
    Me.TX_Index = 1
    Call Lock_Champ
End Sub
 
 
Private Sub BP_Annule_Click()
    Call Tri_Nom
    Me.Hide
    Unload Me
End Sub
 
Private Sub UserForm_Terminate()
    Application.ScreenUpdating = True
    Sheets("Liste").Select
    Cells(3, 1).Select
    ActiveWorkbook.Save
    Call HideExcel
    UF_Accueil.Show
End Sub
Userform commande (non fonctionnel)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
Private Sub UserForm_Initialize()
    Sheets("Commande").Select
    Me.TX_Index = Cells(1, 1)
    Me.TX_Livraison.Clear
    Me.TX_Livraison.AddItem "Sur Place"
    Me.TX_Livraison.AddItem "A Domicile"
End Sub
 
Private Sub UserForm_Activate()
'ajout suite problème
    Sheets("Commande").Select
    Me.TX_Livraison.Clear
    Me.TX_Livraison.AddItem "Sur Place"
    Me.TX_Livraison.AddItem "A Domicile"
    Me.TX_Index = Cells(1, 1)
End Sub
 
Private Sub BP_Ferme_Click()
' tri des commandes par date
    If Me.BP_Ferme.Enabled = False Then Exit Sub
 
    If Cells(1, 1) <> 0 Then Call Tri_Commande
    Range("A3:A3").Select
    Unload Me
End Sub
 
Private Sub UserForm_Terminate()
'ferme la fenetre et fait re-apparaitre la fenetre principale
    If Me.BP_Ferme.Enabled = False Then Exit Sub
 
    Application.ScreenUpdating = True
    Sheets("Liste").Select
    Cells(3, 1).Select
    ActiveWorkbook.Save
    Call HideExcel
    UF_Accueil.Show
End Sub
routines additionnelles
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
Sub ShowExcel()
Dim Fiche As String
 
    Fiche = Appli
    Application.ScreenUpdating = True
    Application.Visible = True
    Application.WindowState = xlMaximized
'ajout des 3 lignes ci-dessous pour réellement afficher la fenêtre
    Windows(Fiche).Visible = True
    Application.Windows(Fiche).WindowState = xlMaximized
    Application.Windows(Fiche).Activate
 
    If admin Then
        Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",True)"
        Application.CommandBars("Formatting").Enabled = True
        Application.CommandBars("Cell").Enabled = True
    Else
        Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)"
        Application.CommandBars("Formatting").Enabled = False
        Application.CommandBars("Cell").Enabled = False
    End If
    ActiveWindow.Visible = True
End Sub
 
Sub HideExcel()
Dim Fiche As String
 
    Fiche = Appli
    If Not (admin) Then
        Application.Visible = False
        Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)"
        Application.CommandBars("Formatting").Enabled = False
        Application.CommandBars("Cell").Enabled = False
    End If
End Sub
 
 
Function admin() As Boolean
    ret = GetSetting(appname:="SMS", section:="Parametre", Key:="Admin")
    If ret = "1" Then
        admin = True
    Else
        admin = False
    End If
End Function
 
Function Appli() As String
    Appli = GetSetting(appname:="SMS", section:="Parametre", Key:="Application")
    If Appli = "" Then
        Appli = "Campagne de SMS.xls"
    End If
End Function
Cordialement.