Dim cb As CommandBar
bereits hier erhalte ich
"Fehler beim kompilieren!
benutzerdefinierter Typ nicht definiert"
Was muss ich machen dass ich cb als CommandBar deklarieren kann??
Dim cb As CommandBar
bereits hier erhalte ich
"Fehler beim kompilieren!
benutzerdefinierter Typ nicht definiert"
Was muss ich machen dass ich cb als CommandBar deklarieren kann??
in diese Arbeitsmappe:
Private Sub Workbook_Open()
'========================================================================================
'2002-02-20, Michael Scheffler, IMA
' Creates export menu
'========================================================================================
CreateMenu
End Sub
in ein Modeul:
Sub CreateMenu()
'========================================================================================
'2002-02-20, Michael Scheffler, IMA
' Creates a new menu
'========================================================================================
' can also be used to create commandbarbuttons
' may be automatically executed from an Auto_Open macro or a Workbook_Open eventmacro
Dim cbMenu As CommandBarControl, cbSubMenu As CommandBarControl
RemoveMenu ' delete the menu if it already exists
' create a new menu on an existing commandbar (the next 6 lines)
Set cbMenu = Application.CommandBars(1).Controls.Add(msoControlPopup, , , , True)
With cbMenu
.Caption = "&HSB-Abfrage"
.Tag = "MyTag"
.BeginGroup = False
End With
' or add to an existing menu (use the next line instead of the previous 6 lines)
'Set cbMenu = Application.CommandBars.FindControl(, 30007) ' Tools-menu
If cbMenu Is Nothing Then Exit Sub ' didn't find the menu...
' add menuitem to menu
With cbMenu.Controls.Add(msoControlButton, 1, , , True)
.Caption = "&Los!"
.OnAction = ThisWorkbook.Name & "!Main"
End With
Set cbSubMenu = Nothing
Set cbMenu = Nothing
End Sub
Gruß
Micha