Bonjour,

J'ai un petit souci, j'ai crée dans 2 fichiers VBA Excel:
2 barres d'état personnalisée et elles fonctionnent.

Si j’ouvre ces fichiers par Excel/fichier/ouvrir, chaque fichier aura sa propre barre d’état personnalisée mais si je les ouvre en direct par « mes documents » + double clic.
Le dernier fichier ouvert fait disparaître la barre du premier fichier ouvert et j’ai les 2 fichiers avec la même barre.
J'espère que j'ai été clair.

Je voudrais que chaque fichier garde sa propre barre personnalisée.

La construction du code étant le même pour chaque barre, juste les menus
sont différents.

MERCI PAR AVANCE

Norbert

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
54
55
 
Sub Auto_Open()
Call Creation_Barres_Consolidation
end sub
 
Sub Creation_Barres_Consolidation()
Dim BAR As Variant
Application.ScreenUpdating = False
On Error Resume Next
 
For Each BAR In Application.CommandBars
    If Not BAR.BuiltIn And BAR.Visible Then BAR.Delete
Next
    Set barre1 = CommandBars.Add(Name:="Labarre", Position:=msoBarTop, MenuBar:=True, temporary:=True)
 
'affichage_barres()
    For Each cbar In CommandBars
        Test = cbar.Index
        If CommandBars("Labarre").Visible = True Then
           CommandBars("Labarre").Enabled = False
        End If
    Next
        barre1.Visible = True
        CommandBars("Labarre").Visible = True
 
'ajout barres de menus
    Set menu1 = barre1.Controls.Add(Type:=msoControlPopup) 'Sauvegarde
    Set menu6 = barre1.Controls.Add(Type:=msoControlPopup) 'Modification
    Set menu7 = barre1.Controls.Add(Type:=msoControlPopup) 'Impression
 
' ajout_sous_menus
    Set opt11 = menu1.Controls.Add(Type:=msoControlButton, ID:=3) 'Sauvegarde
    Set opt61 = menu6.Controls.Add(Type:=msoControlButton, ID:=47) 'Rendre visible tous les onglets
    Set opt71 = menu7.Controls.Add(Type:=msoControlButton, ID:=37) 'Retour Menu Excel
 
'INTITULE DES SOUS MENUS
 ' Saisie
    menu1.Caption = "SAUVEGARDE"
    opt11.Caption = "Sauvegarde"
 
   ' Encadrement
    menu6.Caption = "AFFICHER"
    opt61.Caption = "Rendre visible tous les onglets"
 
' Retour
    menu7.Caption = "RETOUR"
    opt71.Caption = "Retour au Menu Excel"
 
' ATTRIBUTION DES PROCEDURES
    opt11.OnAction = "Enregistrer"
     opt61.OnAction = "RendreVisible"
     opt71.OnAction = "Retour"
 
Application.ScreenUpdating = True
End Sub