HideCloseButton
16.12.2005 23:03:34
Gregor
das funktioniert bei meinem Excel 9 aber nicht bei Excel 2003
dazu verwende ich:
Option Explicit
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
Const WS_SYSMENU = &H80000
Const GWL_STYLE = (-16)
Sub HideCloseButton(oDialog As Object)
Dim hWnd As Long, lStyle As Long
Select Case Int(Val(Application.Version))
Case 8
hWnd = FindWindow("ThunderXFrame", oDialog.Caption)
Case 9
hWnd = FindWindow("ThunderDFrame", oDialog.Caption)
Case 10
hWnd = FindWindow("ThunderDFrame", oDialog.Caption)
End Select
lStyle = GetWindowLong(hWnd, GWL_STYLE)
SetWindowLong hWnd, GWL_STYLE, lStyle And Not WS_SYSMENU
End Sub
Private Sub UserForm_Initialize()
HideCloseButton Me
End Sub
Gibt es auch noch eine schlankere Methode ?