gibt es eine Möglichkeit, es zu verhindern dass Excel über das obligatorische Rote Kreuz geschlossen werden kann?
Gruß
Robert
Function FindWindow Lib "User32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare
Function GetWindowLong Lib "User32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Declare
Function SetWindowLong Lib "User32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare
Function DrawMenuBar Lib "User32" (ByVal hWnd As Long) As Long
Sub Hide_SYSMENU()
Dim xl_hwnd, lStyle
xl_hwnd = FindWindow("xlmain", vbNullString)
If xl_hwnd <> 0 Then
lStyle = GetWindowLong(xl_hwnd, GWL_STYLE)
lStyle = SetWindowLong(xl_hwnd, GWL_STYLE, lStyle And Not WS_SYSMENU)
DrawMenuBar xl_hwnd
End If
End Sub
Sub Show_SYSMENU()
Dim xl_hwnd, lStyle
xl_hwnd = FindWindow("xlmain", vbNullString)
If xl_hwnd <> 0 Then
lStyle = GetWindowLong(xl_hwnd, GWL_STYLE)
lStyle = SetWindowLong(xl_hwnd, GWL_STYLE, lStyle Or WS_SYSMENU)
DrawMenuBar xl_hwnd
End If
End Sub
Aus dem Workbook_Open Ereignis das "Hide_SYSMENU" aufrufen, und im Workbook_BeforeClose Ereignis das Show_SYSMENU aufrufen.
Gruss Rainer
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = True
End Sub
Die erweiterte Suchfunktion hilft dir, gezielt die besten Antworten zu finden
Suche nach den besten AntwortenEntdecke unsere meistgeklickten Beiträge in der Google Suche
Top 100 Threads jetzt ansehen