Bonjour à tous,
Voici un code que j'utilise pour permettre de ne pas afficher les menu, croix pour fermer Excel...etc.
Le problème avec ce code c'est qu'il supprime toutes les commandBars. Je voudrais toutes les supprimer sauf celles pour "réduire et agrandir" Excel.
Pouvez vous m'aider à modifier le code en fonction ?
Merci beaucoup.
Code :
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_open()
Dim hwnd As Long
hwnd = FindWindowA(vbNullString, Application.Caption)
SetWindowLongA hwnd, -16, GetWindowLongA(hwnd, -16) And &HFFF7FFFF
Dim CmdB As CommandBar
For Each CmdB In Application.CommandBars
CmdB.Enabled = False
Next CmdB
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim hwnd As Long
hwnd = FindWindowA(vbNullString, Application.Caption)
SetWindowLongA hwnd, -16, GetWindowLongA(hwnd, -16) Or &H80000
Dim CmdB As CommandBar
For Each CmdB In Application.CommandBars
CmdB.Enabled = True
Next CmdB
End Sub
Voici un code que j'utilise pour permettre de ne pas afficher les menu, croix pour fermer Excel...etc.
Le problème avec ce code c'est qu'il supprime toutes les commandBars. Je voudrais toutes les supprimer sauf celles pour "réduire et agrandir" Excel.
Pouvez vous m'aider à modifier le code en fonction ?
Merci beaucoup.
Code :
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_open()
Dim hwnd As Long
hwnd = FindWindowA(vbNullString, Application.Caption)
SetWindowLongA hwnd, -16, GetWindowLongA(hwnd, -16) And &HFFF7FFFF
Dim CmdB As CommandBar
For Each CmdB In Application.CommandBars
CmdB.Enabled = False
Next CmdB
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim hwnd As Long
hwnd = FindWindowA(vbNullString, Application.Caption)
SetWindowLongA hwnd, -16, GetWindowLongA(hwnd, -16) Or &H80000
Dim CmdB As CommandBar
For Each CmdB In Application.CommandBars
CmdB.Enabled = True
Next CmdB
End Sub