Forumbeitrag
Excel-Version des Fragestellers:
2022
Erfahrungslevel des Fragestellers:
Excel gut - VBA bescheiden
Vollbild nach minimieren in der Taskleiste
Hallo,
ich habe da ein Problem, bei dem ich nicht weiter komme.
Ich habe mir eine Excel Datei erstellt mit vielen Funktionen. Unteranderen wir deim Start der Datei alles auf Vollbild gesetzt. Keine einzige Funktion ist sichtbar, nur die reine Oberfläche mit meinen Macro-Funktionen. Ich habe sehr gute Hilfe hier aus dem Forum dafü bekommen.
Was ich jetzt noch bräuchte ist eine Fnktion, das beim Maximieren aus der Taskleiste, ich wieder den ursprünglichen Vollbildmodus habe.
Ich habe einen Button mit Macro, womit ich miniemieren kann.
Sub Minimieren()
Application.WindowState = xlMinimized
End Sub
Ich sende 2 Bilder mit, wo man das vor dem minimieren in der Taskleiste sieht und nach dem maximieren aus der Taskleiste.
Ich habe mir da ein kleines Macro gebastelt, wo ich es über einen Button ändern kann.
Sub Max()
Application.WindowState = xlNormal
Call AllesAus
End Sub
Jetzt sollte es automatisch nach dem maximieren aus der Taskleiste von Windows wieder ein Vollbildmodus sein.
Hier das Macro für den Vollbildmodus
Option Explicit
Private Declare PtrSafe Function GetWindowRect Lib "user32" ( _
ByVal hWnd As LongPtr, lpRect As RECT) As Long
Private Declare PtrSafe Function SetWindowPos Lib "user32" ( _
ByVal hWnd As LongPtr, ByVal hWndInsertAfter As LongPtr, _
ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, _
ByVal wFlags As Long) As Long
#If Win64 Then
Private Declare PtrSafe Function GetWindowLongA Lib "user32" Alias "GetWindowLongPtrA" ( _
ByVal hWnd As LongPtr, ByVal nIndex As Long) As LongPtr
Private Declare PtrSafe Function SetWindowLongA Lib "user32" Alias "SetWindowLongPtrA" ( _
ByVal hWnd As LongPtr, ByVal nIndex As Long, ByVal dwNewLong As LongPtr) As LongPtr
#Else
Private Declare PtrSafe Function GetWindowLongA Lib "user32" ( _
ByVal hWnd As LongPtr, ByVal nIndex As Long) As LongPtr
Private Declare PtrSafe Function SetWindowLongA Lib "user32" ( _
ByVal hWnd As LongPtr, ByVal nIndex As Long, ByVal dwNewLong As LongPtr) As LongPtr
#End If
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Const GWL_STYLE As Long = (-16)
Private Const SWP_MYSTYLE As Long = &H224 ' SWP_NOZORDER + SWP_FRAMECHANGED + SWP_NOREPOSITION
Private Const WS_MYSTYLE As Long = &HCB0000 ' WS_CAPTION + WS_SYSMENU + WS_MAXIMINIMIZEBOX
Private Sub AusEin1(ByVal bWie As Boolean)
Dim hStil As LongPtr, R As RECT
With Application
GetWindowRect .hWnd, R
If bWie Then
.ExecuteExcel4Macro "Show.Toolbar(""Ribbon"", true)"
Else
.ExecuteExcel4Macro "Show.Toolbar(""Ribbon"", false)"
End If
.DisplayStatusBar = bWie ' Statusbar ein/aus
.DisplayFormulaBar = bWie ' Eingabefeld ein/aus
With ActiveWindow
.DisplayWorkbookTabs = bWie ' Register ein/aus
.DisplayHeadings = bWie ' Zeilen/Spaltenbezeichnungen ein/aus
.DisplayHorizontalScrollBar = bWie ' Scrollleiste ein/aus
.DisplayVerticalScrollBar = bWie ' Scrollleiste ein/aus
End With
hStil = GetWindowLongA(.hWnd, GWL_STYLE)
SetWindowLongA .hWnd, GWL_STYLE, IIf(bWie, hStil Or WS_MYSTYLE, hStil And Not WS_MYSTYLE)
SetWindowPos .hWnd, 0, R.Left, R.Top, R.Right - R.Left, R.Bottom - R.Top, SWP_MYSTYLE
End With
End Sub
Public Sub AllesAus()
Call AusEin2(False)
End Sub
Public Sub AllesEin()
Call AusEin2(True)
End Sub
Private Sub AusEin2(ByVal bWie As Boolean)
' Alternative mit gleichen Funktionen
Dim hStil As LongPtr, R As RECT
With Application
GetWindowRect .hWnd, R
.DisplayFullScreen = Not bWie ' Vollbild ein/aus
.DisplayStatusBar = bWie ' Statusbar ein/aus
.DisplayFormulaBar = bWie ' Eingabefeld ein/aus
With ActiveWindow
.DisplayWorkbookTabs = bWie ' Register ein/aus
.DisplayHeadings = bWie ' Zeilen/Spaltenbezeichnungen ein/aus
.DisplayHorizontalScrollBar = bWie ' Scrollleiste ein/aus
.DisplayVerticalScrollBar = bWie ' Scrollleiste ein/aus
End With
hStil = GetWindowLongA(.hWnd, GWL_STYLE)
SetWindowLongA .hWnd, GWL_STYLE, IIf(bWie, hStil Or WS_MYSTYLE, hStil And Not WS_MYSTYLE)
SetWindowPos .hWnd, 0, R.Left, R.Top, R.Right - R.Left, R.Bottom - R.Top, SWP_MYSTYLE
End With
End Sub
Ich hoffe es kann mir einer helfen.
LG Hans