Excel VBA

  • Thread starter Michael Yayannis
  • Start date
M

Michael Yayannis

Hallo NG!

Wie füge ich in excel per VBA-Code ein benutzerdefiniertes Menüelement das
zB Makro1 ausführt?

Danke und Gruß
 
M

Martin Seelhofer

Hi Michael
Wie füge ich in excel per VBA-Code ein benutzerdefiniertes Menüelement das
zB Makro1 ausführt?

Sub menutest()
Dim popup As CommandBarPopup
' Das folgende Beispiel ist für Excel, in Word wäre der Name
' der Menuleiste einfach nur "Menu Bar"
Set popup = CommandBars("Worksheet Menu
Bar").Controls.Add(msoControlPopup)
With popup
.Caption = "Mein Menu"
With .Controls.Add(msoControlButton)
.Caption = "Mein Befehl"
.OnAction = "MeinMakro" ' <--- hier musst Du Deinen
Makronamen hinschreiben
End With
End With
End Sub


Sub meinMakro()
MsgBox "Hallo Welt"
End Sub



Cheers,
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top