Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
ChrisV
Bonjour Andy38,
Dans un module du classeur ---------------------------------------
Sub ajouM() Set newM = CommandBars(1).Controls.Add(Type:=msoControlPopup, _ Before:=CommandBars(1).Controls("?").Index, Temporary:=True) newM.Caption = "&MPFE" Set cmd1 = CommandBars(1).Controls("MPFE").Controls.Add(msoControlPopup) With cmd1 .Caption = "&Menu1" .Controls.Add (msoControlButton) With .Controls(1) .Caption = "Sous-menu&1" .OnAction = "Bonjour" .FaceId = 342 End With .Controls.Add (msoControlButton) With .Controls(2) .Caption = "Sous-menu&2" .OnAction = "Salut" .FaceId = 352 End With End With Set cmd2 = CommandBars(1).Controls("MPFE").Controls.Add With cmd2 .Caption = "Me&nu2" .OnAction = "aBientot" End With Set newM = Nothing Set cmd1 = Nothing Set cmd2 = Nothing End Sub
Sub supM() On Error Resume Next Application.CommandBars(1).Controls("MPFE").Delete End Sub
Sub Bonjour() MsgBox "Hello !" End Sub
Sub Salut() MsgBox "Au revoir !" End Sub
Sub aBientot() MsgBox "A bientôt sur MPFE !" End Sub
Dans la feuille de code de ThisWorkbook ---------------------------------------------------------
Private Sub Workbook_Open() ajouM End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean) supM End Sub
Private Sub Workbook_WindowActivate(ByVal Wn As Window) On Error Resume Next Application.CommandBars(1).Controls("MPFE").Visible = True End Sub
Private Sub Workbook_WindowDeactivate(ByVal Wn As Window) On Error Resume Next Application.CommandBars(1).Controls("MPFE").Visible = False End Sub
ChrisV
"andy38" a écrit dans le message de news:
comment creer des menus principaux ainsi que des sous-menus. Genre arboressence.
Bonjour Andy38,
Dans un module du classeur
---------------------------------------
Sub ajouM()
Set newM = CommandBars(1).Controls.Add(Type:=msoControlPopup, _
Before:=CommandBars(1).Controls("?").Index, Temporary:=True)
newM.Caption = "&MPFE"
Set cmd1 = CommandBars(1).Controls("MPFE").Controls.Add(msoControlPopup)
With cmd1
.Caption = "&Menu1"
.Controls.Add (msoControlButton)
With .Controls(1)
.Caption = "Sous-menu&1"
.OnAction = "Bonjour"
.FaceId = 342
End With
.Controls.Add (msoControlButton)
With .Controls(2)
.Caption = "Sous-menu&2"
.OnAction = "Salut"
.FaceId = 352
End With
End With
Set cmd2 = CommandBars(1).Controls("MPFE").Controls.Add
With cmd2
.Caption = "Me&nu2"
.OnAction = "aBientot"
End With
Set newM = Nothing
Set cmd1 = Nothing
Set cmd2 = Nothing
End Sub
Sub supM()
On Error Resume Next
Application.CommandBars(1).Controls("MPFE").Delete
End Sub
Sub Bonjour()
MsgBox "Hello !"
End Sub
Sub Salut()
MsgBox "Au revoir !"
End Sub
Sub aBientot()
MsgBox "A bientôt sur MPFE !"
End Sub
Dans la feuille de code de ThisWorkbook
---------------------------------------------------------
Private Sub Workbook_Open()
ajouM
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
supM
End Sub
Private Sub Workbook_WindowActivate(ByVal Wn As Window)
On Error Resume Next
Application.CommandBars(1).Controls("MPFE").Visible = True
End Sub
Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
On Error Resume Next
Application.CommandBars(1).Controls("MPFE").Visible = False
End Sub
ChrisV
"andy38" <andy38@discussions.microsoft.com> a écrit dans le message de news:
66CB9CAB-E3A7-43C8-A90D-62F3BD4050E7@microsoft.com...
comment creer des menus principaux ainsi que des sous-menus. Genre
arboressence.
Dans un module du classeur ---------------------------------------
Sub ajouM() Set newM = CommandBars(1).Controls.Add(Type:=msoControlPopup, _ Before:=CommandBars(1).Controls("?").Index, Temporary:=True) newM.Caption = "&MPFE" Set cmd1 = CommandBars(1).Controls("MPFE").Controls.Add(msoControlPopup) With cmd1 .Caption = "&Menu1" .Controls.Add (msoControlButton) With .Controls(1) .Caption = "Sous-menu&1" .OnAction = "Bonjour" .FaceId = 342 End With .Controls.Add (msoControlButton) With .Controls(2) .Caption = "Sous-menu&2" .OnAction = "Salut" .FaceId = 352 End With End With Set cmd2 = CommandBars(1).Controls("MPFE").Controls.Add With cmd2 .Caption = "Me&nu2" .OnAction = "aBientot" End With Set newM = Nothing Set cmd1 = Nothing Set cmd2 = Nothing End Sub
Sub supM() On Error Resume Next Application.CommandBars(1).Controls("MPFE").Delete End Sub
Sub Bonjour() MsgBox "Hello !" End Sub
Sub Salut() MsgBox "Au revoir !" End Sub
Sub aBientot() MsgBox "A bientôt sur MPFE !" End Sub
Dans la feuille de code de ThisWorkbook ---------------------------------------------------------
Private Sub Workbook_Open() ajouM End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean) supM End Sub
Private Sub Workbook_WindowActivate(ByVal Wn As Window) On Error Resume Next Application.CommandBars(1).Controls("MPFE").Visible = True End Sub
Private Sub Workbook_WindowDeactivate(ByVal Wn As Window) On Error Resume Next Application.CommandBars(1).Controls("MPFE").Visible = False End Sub
ChrisV
"andy38" a écrit dans le message de news:
comment creer des menus principaux ainsi que des sous-menus. Genre arboressence.