AW: Im VBA Editor Makro ausführen mit Schaltfläche
05.10.2010 14:37:04
bst
Hallo,
reicht Dir so etwas als Ansatz?
Habe ich noch auf meiner Platte gefunden, woher das auch stammen mag...
HTH, Bernd
--
Option Explicit
Dim WithEvents cbb As Office.CommandBarButton
Private Sub Workbook_Open()
' Dim vbe As Object
' Dim cb As Office.CommandBar
' Dim cbc As Office.CommandBarControl
' Set vbe = Application.vbe
' Set cb = vbe.CommandBars(1)
' Set cbc = cb.Controls("E&xtras")
' Set cb = cbc.CommandBar
' Set cbb = cb.Controls.Add(msoControlButton)
Set cbb = Application.vbe.CommandBars(1).Controls("E&xtras").CommandBar.Controls.Add( _
msoControlButton)
With cbb
.Caption = "New Button"
.TooltipText = "Klick mich ..."
End With
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.vbe.CommandBars(1).Controls("E&xtras").Controls("New Button").Delete
End Sub
Private Sub cbb_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
MsgBox Ctrl.Caption & " wurde gedrückt."
End Sub