Gruppe
Menue
Bereich
Bar
Thema
Beim Öffnen Menüleiste anlegen und auf ganzen Bildschirm schalten
Problem
Wie kann ich beim Öffnen einer Arbeitsmappe eine eigene Menüleiste anlegen und anzeigen lassen. Außerdem soll auf "Ganzer Bildschirm" geschaltet werden.
Lösung
Geben Sie den Ereigniscode in das Klassenmodul der Arbeitsmappe ein.
ClassModule: DieseArbeitsmappe
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call CmdDelete
End Sub
Private Sub Workbook_Open()
Dim oBar As CommandBar
Dim oBtn As CommandBarButton
Call CmdDelete
Set oBar = Application.CommandBars.Add( _
Name:="MyFiles", _
Position:=msoBarTop, _
MenuBar:=True)
Set oBtn = oBar.Controls.Add
With oBtn
.Caption = "Laden"
.Style = msoButtonCaption
End With
Set oBtn = oBar.Controls.Add
With oBtn
.Caption = "Speichern"
.Style = msoButtonCaption
End With
Set oBtn = oBar.Controls.Add
With oBtn
.Caption = "Erstellen"
.Style = msoButtonCaption
End With
Set oBtn = oBar.Controls.Add
With oBtn
.Caption = "Zurück"
.OnAction = "CmdDelete"
.Style = msoButtonCaption
End With
Set oBtn = oBar.Controls.Add(ID:=178)
Application.DisplayFullScreen = True
oBar.Visible = True
End Sub
StandardModule: basMain
Sub CmdDelete()
On Error GoTo ERRORHANDLER
Application.CommandBars("MyFiles").Delete
Application.DisplayFullScreen = False
ERRORHANDLER:
End Sub