Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

enlever la croix Excel

1 réponse
Avatar
Sunburn
Bonjour,
je voudrais supprimer la croix de l'application Excel, afin d'obliger les
gens à sortir via un bouton Perso.
J'ai trouver ceci sur code-vba.
--
Sub supprimer_croix_sys()
Dim hwnd As Long
hwnd = FindWindowA(vbNullString, Application.Caption)
SetWindowLongA hwnd, -16, GetWindowLongA(hwnd, -16) And &HFFF7FFFF
End Sub
----
Sub restaurer_croix_sys()
Dim hwnd As Long
hwnd = FindWindowA(vbNullString, Application.Caption)
SetWindowLongA hwnd, -16, GetWindowLongA(hwnd, -16) Or &H80000
End Sub
----
ça plante car il me dit que FindWindowA n'est pas défini.
j'ai rajouté ceci, qui était aussi dans le code.
----
Option Explicit

Private Declare Function GetWindowLongA Lib "user32" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long


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


Private Declare Function SetWindowLongA Lib "user32" _
(ByVal hwnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
-----
Mais à partir de ce moment là, mon classeur bug...
pourquoi ????
Merci.
YANN

1 réponse

Avatar
Daniel.j
Bonjour
Esssaie comme celle la :

'Dans le module ThisWorkbook de l'application :
Private Declare Function FindWindowA Lib "User32" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Declare Function GetWindowLongA Lib "User32" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long

Private Declare Function SetWindowLongA Lib "User32" _
(ByVal hwnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim hwnd As Long
hwnd = FindWindowA(vbNullString, Application.Caption)
SetWindowLongA hwnd, -16, GetWindowLongA(hwnd, -16) Or &H80000
End Sub

Private Sub Workbook_Open()
Dim hwnd As Long
hwnd = FindWindowA(vbNullString, Application.Caption)
SetWindowLongA hwnd, -16, GetWindowLongA(hwnd, -16) And &HFFF7FFFF
End Sub


Daniel

--
FAQ MPFE
http://dj.joss.free.fr/faq.htm

VBAXL
http://dj.joss.free.fr/

"Sunburn" a écrit dans le message de
news:
Bonjour,
je voudrais supprimer la croix de l'application Excel, afin d'obliger les
gens à sortir via un bouton Perso.
J'ai trouver ceci sur code-vba.
--
Sub supprimer_croix_sys()
Dim hwnd As Long
hwnd = FindWindowA(vbNullString, Application.Caption)
SetWindowLongA hwnd, -16, GetWindowLongA(hwnd, -16) And &HFFF7FFFF
End Sub
----
Sub restaurer_croix_sys()
Dim hwnd As Long
hwnd = FindWindowA(vbNullString, Application.Caption)
SetWindowLongA hwnd, -16, GetWindowLongA(hwnd, -16) Or &H80000
End Sub
----
ça plante car il me dit que FindWindowA n'est pas défini.
j'ai rajouté ceci, qui était aussi dans le code.
----
Option Explicit

Private Declare Function GetWindowLongA Lib "user32" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long


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


Private Declare Function SetWindowLongA Lib "user32" _
(ByVal hwnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
-----
Mais à partir de ce moment là, mon classeur bug...
pourquoi ????
Merci.
YANN