Kann ich in VBA den Fenster-Schließ-Button der sich oben rechts in jeder Form befindet ausblenden wie bei VB?
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 0 Then Cancel = True
End Sub
Private Darf
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Darf <> "J" Then
Cancel = True
MsgBox "Du darfst das nicht!"
End If
Darf = "N"
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Darf <> "J" Then
Cancel = True
MsgBox "Datei nicht gesichert, Du darfst das nicht!"
End If
Darf = "N"
End Sub
Sub sichern()
Darf = "J" ' damit du überhaupt mal sichern oder beenden kannst
End Sub
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
Private Declare Function DrawMenuBar Lib "User32" ( _
ByVal hWnd As Long) As Long
Private Const GWL_STYLE = -&H10
Private Const WS_SYSMENU = &H80000
Private Sub UserForm_Activate()
Dim lHwnd As Long
lHwnd = FindWindow("ThunderDFrame", Me.Caption)
SetWindowLong lHwnd, GWL_STYLE, GetWindowLong(lHwnd, GWL_STYLE) And Not WS_SYSMENU
DrawMenuBar lHwnd
End Sub