OVH Cloud OVH Cloud

Interdire fermeture Excel

1 réponse
Avatar
christophe
Bonjour, j'aurais voulu savoi comment on peut enlever "la petite croix de
fermeture" de Excel.
ou de détecter la fermeture .
Merci d'avance.

1 réponse

Avatar
denis P
Bonjour christophe,

Le plus simple est de mettre un petit papier collant pour la cacher...

;-)

Dans un module standard, copie ce qui suit :

(ne bloc pas le menu Fichier -> quiter)

Code publié ici sous la plume de F.Sigonneau et A. Cros, je crois...

'-------------------------
Private Declare Function FindWindowA Lib "user32" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

Private Declare Function GetClassLong Lib "user32" _
Alias "GetClassLongA" _
(ByVal hWnd As Long, _
ByVal nIndex As Long) As Long

Private Declare Function SetClassLong Lib "user32" _
Alias "SetClassLongA" _
(ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long


Sub RestaureLaCroix()

Dim LeHandleExcel As Long

Const GCL_STYLE = (-26)
Const CS_NOCLOSE = &H200

LeHandleExcel = FindWindowA("XLMAIN", Application.Caption)
SetClassLong LeHandleExcel, GCL_STYLE, _
GetClassLong(LeHandleExcel, GCL_STYLE) _
Xor CS_NOCLOSE

End Sub


Sub EnleveLaCroix()

Dim LeHandleExcel As Long

Const GCL_STYLE = (-26)
Const CS_NOCLOSE = &H200

LeHandleExcel = FindWindowA("XLMAIN", Application.Caption)
SetClassLong LeHandleExcel, GCL_STYLE, _
GetClassLong(LeHandleExcel, GCL_STYLE) _
Xor CS_NOCLOSE

End Sub
'-------------------------




"christophe" a écrit dans le message
de news:
Bonjour, j'aurais voulu savoi comment on peut enlever "la petite croix de
fermeture" de Excel.
ou de détecter la fermeture .
Merci d'avance.