AW: "Excel" ausblenden?
31.08.2003 12:12:28
Nepumuk
Hallo Benjamin,
folgenden Code in das Klassenmodul "DieseArbeitsmappe":
Option Explicit
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Show_SYSMENU
End Sub
Private Sub Workbook_Open()
Hide_SYSMENU
End Sub
folgenden Code in ein normales Modul:
Option Explicit
Public Const GWL_STYLE = (-16)
Public Const WS_SYSMENU = &H80000
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
Public 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
Public 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
Code eingefügt mit: Excel Code Jeanie
Gruß
Nepumuk
P.S. Aber dann kann Excel immer noch über das Fenster in der Taskleiste geschlossen werden! Das könnte auch deaktiviert werden.