Hallo GraFri - Dein Menü-Code
14.10.2003 19:05:35
Jana
Hier nochmal Deine Nachricht!
>>>>>
Hallo
Hier ein Beispiel für Menü mit Untermenü. Alles in ein Modul. Deinen Vorstellungen anpassen.
Sub Auto_Open()
Set ML = Application.CommandBars("Worksheet Menu Bar")
' Name für neues Menü wird gesetzt
Set U1 = ML.Controls.Add(Type:=msoControlPopup, Before:=10)
U1.Caption = "&Werkzeuge"
U1.Tag = "MeinMenü" ' dient zur eindeutigen Identifizierung des Menüs
' 1. Menüpunkt wird angelegt
Set Punkt = U1.Controls.Add(Type:=msoControlButton)
With Punkt
.Caption = "&1. Menüpunkt"
.OnAction = "Makro1"
.Style = msoButtonIconAndCaption
.FaceId = 2103
End With
' neues Untermenü wird hinzugefügt
Set Punkt = U1.Controls.Add(Type:=msoControlPopup)
With Punkt
.Caption = "1.Untermenü"
End With
Set U2 = Punkt ' Variable für das 2. Untermenü wird gesetzt
'Neuer Menüeintrag im 2.Untermenü
Set Punkt = U2.Controls.Add(Type:=msoControlButton)
With Punkt
.Caption = "&2.Menüpunkt"
.OnAction = "Makro2"
.Style = msoButtonIconAndCaption
.FaceId = 144
End With
Set Punkt = U2.Controls.Add(Type:=msoControlButton)
With Punkt
.Caption = "&3.Menüpunkt"
.OnAction = "Makro3"
.Style = msoButtonIconAndCaption
.FaceId = 1715
End With
' Weiterer Eintrag im 1.Untermenü
Set Punkt = U1.Controls.Add(Type:=msoControlButton)
With Punkt
.Caption = "&4.Menüeintrag"
.OnAction = "Makro4"
.Style = msoButtonIconAndCaption
.FaceId = 3200
End With
End Sub
Sub Auto_Close()
Set ML = Application.CommandBars("Worksheet Menu Bar")
On Error Resume Next ' Fehlerbehandlung
ML.FindControl(Tag:="MeinMenü").Delete
End Sub
<<<<