title image


Smiley Re: Menüleiste mit Controlpopups: wie Controlbutton hinzufügen?
Hallo Maddin,



Wo sind deine Deklarationen? Arbeitest du immer noch ohne Option Explicit? :-(

Wo ist die Fehlerroutine? Außerdem solltest du die Leiste beim schließen der Mappe wieder löschen. Könnte ja sein, dass der User noch eine Mappe im selben Container offen hat. Dazu musst du das löschen der Commandbar in eine eigene Routine packen und das ganze im BeforeClose - Ereignis verarbeiten.



' **********************************************************************' Modul: DieseArbeitsmappe Typ: Element der Mappe(Sheet, Workbook, ...)' **********************************************************************Option ExplicitPrivate Sub Workbook_BeforeClose(Cancel As Boolean)    With ThisWorkbook        If Not .Saved And Not .ReadOnly Then            Select Case MsgBox("Änderungen in ''" & .Name & _                        "'' speichern?", vbQuestion + vbYesNoCancel, "Abfrage")                Case vbYes                    .Save                Case vbNo                    .Saved = True                Case vbCancel                    Cancel = True                    Exit Sub            End Select        End If        Call prcDeleteteMenu    End WithEnd SubPrivate Sub Workbook_Open()    Call prcCreateMenuEnd Sub' **********************************************************************' Modul: Modul1 Typ: Allgemeines Modul' **********************************************************************Option ExplicitOption Private ModulePrivate Const TBL_MENUNAME = "Mainmenu"Public Sub prcCreateMenu()    Dim tlbNewMenu As CommandBar    Dim tlbPopup1 As CommandBarPopup, tlbPopup2 As CommandBarPopup    Dim tlbButton As CommandBarButton    On Error GoTo err_exit    Call prcDeleteteMenu    Set tlbNewMenu = CommandBars.Add(Name:=TBL_MENUNAME, _        Position:=msoBarTop, Temporary:=True)    Set tlbPopup1 = tlbNewMenu.Controls.Add(Type:=msoControlPopup)    tlbPopup1.Caption = " Numero Uno "    Set tlbButton = tlbPopup1.Controls.Add(Type:=msoControlButton)    With tlbButton        .Caption = " Alpha "        .FaceId = 18        .Style = msoButtonIconAndCaption        .OnAction = "Alpha"    End With    Set tlbButton = tlbPopup1.Controls.Add(Type:=msoControlButton)    With tlbButton        .Caption = " Bravo "        .FaceId = 23        .Style = msoButtonIconAndCaption        .OnAction = "Bravo"    End With    Set tlbPopup2 = tlbPopup1.Controls.Add(Type:=msoControlPopup)    tlbPopup2.Caption = " Charlie"    Set tlbButton = tlbPopup2.Controls.Add(Type:=msoControlButton)    With tlbButton        .Caption = " Test1 "        .FaceId = 80        .Style = msoButtonIconAndCaption        .OnAction = "Test1"    End With    Set tlbButton = tlbPopup2.Controls.Add(Type:=msoControlButton)    With tlbButton        .Caption = " Test2 "        .FaceId = 81        .Style = msoButtonIconAndCaption        .OnAction = "Test2"    End With    Set tlbButton = tlbPopup2.Controls.Add(Type:=msoControlButton)    With tlbButton        .Caption = " Test3 "        .FaceId = 82        .Style = msoButtonIconAndCaption        .OnAction = "Test3"    End With    tlbNewMenu.Visible = True    Exit Sub    err_exit:    MsgBox "Fehler " & CStr(Err.Number) & vbLf & vbLf & _        Err.Description, vbCritical, "Fehlermeldung"    Call prcDeleteteMenuEnd SubPublic Sub prcDeleteteMenu()    On Error Resume Next    Application.CommandBars(TBL_MENUNAME).DeleteEnd Sub
Gruß
Nepumuk


geschrieben von

Login

E-Mail:
  

Passwort:
  

Beitrag anfügen

Symbol:
 
 
 
 
 
 
 
 
 
 
 
 
 

Überschrift: