utilisation nom de variable pour le nom d'une commandbars
Bonjour le forum :D
J'essaye d'utiliser le nom d'une variable (nom du classeur actif sans extention) pour l'attribuer au nom de la CommandBars, avec la procédure ci-dessous cà bug ???
Code:
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
| Sub CreationCB()
Dim NameCeClasseur As String
NameCeClasseur = Left(ThisWorkbook.Name, Len(ThisWorkbook.Name) - 4)
'MsgBox NameCeClasseur
Dim CB As CommandBar ' Concerne la barre d'outils
Dim msoCCB As CommandBarComboBox ' Concerne le controle ComboBox msoControlComboBox)
Application.ScreenUpdating = False
Set CB = Application.CommandBars.Add(NameCeClasseur, Position:=msoBarFloating, temporary:=True)
With CB
' Attribuer la référence (msoCCB) à la ComboBox à créer
Set msoCCB = CB.Controls.Add(msoControlComboBox, , , , True)
With msoCCB
.Width = 160
.TooltipText = "C'est une ComboBox"
.OnAction = "SelectComboBox"
.Tag = "cbo1"
.AddItem "Menu"
.AddItem "Masquer les lignes"
.AddItem "Afficher les lignes"
.AddItem "Nouvelle ligne"
End With
.Visible = True
With CB
.Left = 1395
.Top = 106
End With
End With
Dim strTxt As String
Set msoCCB = CommandBars(NameCeClasseur).FindControl(, , "cbo1")
strTxt = msoCCB.Text
msoCCB.Text = "Menu"
End Sub |
Pourriez-vous m'expliquer svp si j'ai fait une erreur de syntaxe, merci d'avance
Cordialement Modus57