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

Barre de menus

4 réponses
Avatar
Gildo
Bonjour,

Je cherche à ce que n’apparaissent plus « fichier », « affichage » et «
outils » dans la barre de menus d’un fichier Excel et en plus je souhaite
inhiber le click droit dans cette barre .
Cela est-il possible ?
Par avance merci

4 réponses

Avatar
MichDenis
'---------------------------
Sub test()
On Error Resume Next
Application.CommandBars(1).Controls("Outils").Delete
Application.CommandBars(1).Controls("Affichage").Delete
Application.CommandBars("Toolbar List").Enabled = False
End Sub
'---------------------------

As-tu oublié le double-clic dans l'espace des barres d''outils ?

Pour les versions Excel 2002 et 2003, il y a ceci qui fait le travail :
'-----------------------------
Sub Test_Excel_2002_2003()
Application.CommandBars("Toolbar List").Enabled = False
Application.CommandBars.DisableCustomize = True
End Sub
'-----------------------------

Pour désactiver le double-clic dans la barre d'outils pour les versions plus
anciennes, il y a cette procédure qui fut proposée par Alain Cros.

'******************************************
Dans le module ThisWorkbook

Private Sub Workbook_BeforeClose(Cancel As Boolean)
LeHook
End Sub
Private Sub Workbook_Open()
LeHook True
End Sub

Dans un module ordinaire

Private Declare Function LockWindowUpdate& Lib "user32" ( _
ByVal hwndLock&)
Private Declare Function PostMessage& Lib "user32" _
Alias "PostMessageA" (ByVal hwnd&, ByVal wMsg&, ByVal wParam&, ByVal lParam&)
Private Declare Function FindWindowEx& Lib "user32" _
Alias "FindWindowExA" (ByVal hWnd1&, ByVal hWnd2&, ByVal lpsz1$, ByVal lpsz2$)
Private Declare Function GetWindowLong& Lib "user32" _
Alias "GetWindowLongA" (ByVal hwnd&, ByVal nIndex&)
Private Declare Function GetCurrentThreadId Lib "kernel32" () As Long
Private Declare Function SetWindowsHookEx& Lib "user32" _
Alias "SetWindowsHookExA" (ByVal idHook&, ByVal lpfn&, ByVal hmod&, ByVal dwThreadId&)
Private Declare Function GetWindowText& Lib "user32" _
Alias "GetWindowTextA" (ByVal hwnd&, ByVal lpString$, ByVal cch&)
Private Declare Function UnhookWindowsHookEx& Lib "user32" _
(ByVal hHook&)
Private lgHook&
Sub LeHook(Optional cache As Boolean)
Const GWL_HINSTANCE& = -6
If cache Then
InstallHook GetWindowLong(FindWindowEx(0&, 0&, "XLMAIN", _
Application.Caption), GWL_HINSTANCE)
Else
UnhookWindowsHookEx lgHook
End If
End Sub
Sub InstallHook(lgInst&)
Const WH_CBT& = &H5
#If VBA6 Then
lgHook = SetWindowsHookEx(WH_CBT, AddressOf WinHook, _
lgInst, GetCurrentThreadId)
#Else
lgHook = SetWindowsHookEx(WH_CBT, AddrOf("WinHook"), _
lgInst, GetCurrentThreadId)
#End If
End Sub
Private Function WinHook&(ByVal lMsg&, ByVal wParam&, ByRef lParam&)
Const HCBT_ACTIVATE& = &H5, WM_SYSCOMMAND& = &H112, SC_CLOSE& = &HF060&
Dim MYSTR$
If lMsg = HCBT_ACTIVATE Then
LockWindowUpdate wParam
MYSTR = Space$(100&)
MYSTR = Left$(MYSTR, GetWindowText(wParam, MYSTR, 100&))
If MYSTR = "Personnaliser" Or MYSTR = "Personnalisation" Then
PostMessage wParam, WM_SYSCOMMAND, SC_CLOSE, 0&
Else
LockWindowUpdate False
End If
End If
WinHook = False
End Function
'******************************************



"Gildo" a écrit dans le message de news:

Bonjour,

Je cherche à ce que n'apparaissent plus « fichier », « affichage » et «
outils » dans la barre de menus d'un fichier Excel et en plus je souhaite
inhiber le click droit dans cette barre .
Cela est-il possible ?
Par avance merci
Avatar
Gildo
J'ai tout flingué
j'ai utilisé la sub test dans l'auto open de mon fichier ça marche impec
même un peu trop car mes autres fichiers non concernés par cette macro ce
voient formatés de la même façon.
En bref mon excel n'a plus outils ni affichage



'---------------------------
Sub test()
On Error Resume Next
Application.CommandBars(1).Controls("Outils").Delete
Application.CommandBars(1).Controls("Affichage").Delete
Application.CommandBars("Toolbar List").Enabled = False
End Sub
'---------------------------

As-tu oublié le double-clic dans l'espace des barres d''outils ?

Pour les versions Excel 2002 et 2003, il y a ceci qui fait le travail :
'-----------------------------
Sub Test_Excel_2002_2003()
Application.CommandBars("Toolbar List").Enabled = False
Application.CommandBars.DisableCustomize = True
End Sub
'-----------------------------

Pour désactiver le double-clic dans la barre d'outils pour les versions plus
anciennes, il y a cette procédure qui fut proposée par Alain Cros.

'******************************************
Dans le module ThisWorkbook

Private Sub Workbook_BeforeClose(Cancel As Boolean)
LeHook
End Sub
Private Sub Workbook_Open()
LeHook True
End Sub

Dans un module ordinaire

Private Declare Function LockWindowUpdate& Lib "user32" ( _
ByVal hwndLock&)
Private Declare Function PostMessage& Lib "user32" _
Alias "PostMessageA" (ByVal hwnd&, ByVal wMsg&, ByVal wParam&, ByVal lParam&)
Private Declare Function FindWindowEx& Lib "user32" _
Alias "FindWindowExA" (ByVal hWnd1&, ByVal hWnd2&, ByVal lpsz1$, ByVal lpsz2$)
Private Declare Function GetWindowLong& Lib "user32" _
Alias "GetWindowLongA" (ByVal hwnd&, ByVal nIndex&)
Private Declare Function GetCurrentThreadId Lib "kernel32" () As Long
Private Declare Function SetWindowsHookEx& Lib "user32" _
Alias "SetWindowsHookExA" (ByVal idHook&, ByVal lpfn&, ByVal hmod&, ByVal dwThreadId&)
Private Declare Function GetWindowText& Lib "user32" _
Alias "GetWindowTextA" (ByVal hwnd&, ByVal lpString$, ByVal cch&)
Private Declare Function UnhookWindowsHookEx& Lib "user32" _
(ByVal hHook&)
Private lgHook&
Sub LeHook(Optional cache As Boolean)
Const GWL_HINSTANCE& = -6
If cache Then
InstallHook GetWindowLong(FindWindowEx(0&, 0&, "XLMAIN", _
Application.Caption), GWL_HINSTANCE)
Else
UnhookWindowsHookEx lgHook
End If
End Sub
Sub InstallHook(lgInst&)
Const WH_CBT& = &H5
#If VBA6 Then
lgHook = SetWindowsHookEx(WH_CBT, AddressOf WinHook, _
lgInst, GetCurrentThreadId)
#Else
lgHook = SetWindowsHookEx(WH_CBT, AddrOf("WinHook"), _
lgInst, GetCurrentThreadId)
#End If
End Sub
Private Function WinHook&(ByVal lMsg&, ByVal wParam&, ByRef lParam&)
Const HCBT_ACTIVATE& = &H5, WM_SYSCOMMAND& = &H112, SC_CLOSE& = &HF060&
Dim MYSTR$
If lMsg = HCBT_ACTIVATE Then
LockWindowUpdate wParam
MYSTR = Space$(100&)
MYSTR = Left$(MYSTR, GetWindowText(wParam, MYSTR, 100&))
If MYSTR = "Personnaliser" Or MYSTR = "Personnalisation" Then
PostMessage wParam, WM_SYSCOMMAND, SC_CLOSE, 0&
Else
LockWindowUpdate False
End If
End If
WinHook = False
End Function
'******************************************



"Gildo" a écrit dans le message de news:

Bonjour,

Je cherche à ce que n'apparaissent plus « fichier », « affichage » et «
outils » dans la barre de menus d'un fichier Excel et en plus je souhaite
inhiber le click droit dans cette barre .
Cela est-il possible ?
Par avance merci





Avatar
MichDenis
Dans le ThisWorkbook, tu as des événements

"Activate" et "Desactivate" ... tu les utilises selon le cas
pour iniber les comportements que tu désires ou pour
réactiver ces comportements.

Pour remettre à neuf la barre des menus telle qu'elle était
la commande est :
Application.Application.CommandBars(1).reset



"Gildo" a écrit dans le message de news:

J'ai tout flingué
j'ai utilisé la sub test dans l'auto open de mon fichier ça marche impec
même un peu trop car mes autres fichiers non concernés par cette macro ce
voient formatés de la même façon.
En bref mon excel n'a plus outils ni affichage



'---------------------------
Sub test()
On Error Resume Next
Application.CommandBars(1).Controls("Outils").Delete
Application.CommandBars(1).Controls("Affichage").Delete
Application.CommandBars("Toolbar List").Enabled = False
End Sub
'---------------------------

As-tu oublié le double-clic dans l'espace des barres d''outils ?

Pour les versions Excel 2002 et 2003, il y a ceci qui fait le travail :
'-----------------------------
Sub Test_Excel_2002_2003()
Application.CommandBars("Toolbar List").Enabled = False
Application.CommandBars.DisableCustomize = True
End Sub
'-----------------------------

Pour désactiver le double-clic dans la barre d'outils pour les versions plus
anciennes, il y a cette procédure qui fut proposée par Alain Cros.

'******************************************
Dans le module ThisWorkbook

Private Sub Workbook_BeforeClose(Cancel As Boolean)
LeHook
End Sub
Private Sub Workbook_Open()
LeHook True
End Sub

Dans un module ordinaire

Private Declare Function LockWindowUpdate& Lib "user32" ( _
ByVal hwndLock&)
Private Declare Function PostMessage& Lib "user32" _
Alias "PostMessageA" (ByVal hwnd&, ByVal wMsg&, ByVal wParam&, ByVal lParam&)
Private Declare Function FindWindowEx& Lib "user32" _
Alias "FindWindowExA" (ByVal hWnd1&, ByVal hWnd2&, ByVal lpsz1$, ByVal lpsz2$)
Private Declare Function GetWindowLong& Lib "user32" _
Alias "GetWindowLongA" (ByVal hwnd&, ByVal nIndex&)
Private Declare Function GetCurrentThreadId Lib "kernel32" () As Long
Private Declare Function SetWindowsHookEx& Lib "user32" _
Alias "SetWindowsHookExA" (ByVal idHook&, ByVal lpfn&, ByVal hmod&, ByVal dwThreadId&)
Private Declare Function GetWindowText& Lib "user32" _
Alias "GetWindowTextA" (ByVal hwnd&, ByVal lpString$, ByVal cch&)
Private Declare Function UnhookWindowsHookEx& Lib "user32" _
(ByVal hHook&)
Private lgHook&
Sub LeHook(Optional cache As Boolean)
Const GWL_HINSTANCE& = -6
If cache Then
InstallHook GetWindowLong(FindWindowEx(0&, 0&, "XLMAIN", _
Application.Caption), GWL_HINSTANCE)
Else
UnhookWindowsHookEx lgHook
End If
End Sub
Sub InstallHook(lgInst&)
Const WH_CBT& = &H5
#If VBA6 Then
lgHook = SetWindowsHookEx(WH_CBT, AddressOf WinHook, _
lgInst, GetCurrentThreadId)
#Else
lgHook = SetWindowsHookEx(WH_CBT, AddrOf("WinHook"), _
lgInst, GetCurrentThreadId)
#End If
End Sub
Private Function WinHook&(ByVal lMsg&, ByVal wParam&, ByRef lParam&)
Const HCBT_ACTIVATE& = &H5, WM_SYSCOMMAND& = &H112, SC_CLOSE& = &HF060&
Dim MYSTR$
If lMsg = HCBT_ACTIVATE Then
LockWindowUpdate wParam
MYSTR = Space$(100&)
MYSTR = Left$(MYSTR, GetWindowText(wParam, MYSTR, 100&))
If MYSTR = "Personnaliser" Or MYSTR = "Personnalisation" Then
PostMessage wParam, WM_SYSCOMMAND, SC_CLOSE, 0&
Else
LockWindowUpdate False
End If
End If
WinHook = False
End Function
'******************************************



"Gildo" a écrit dans le message de news:

Bonjour,

Je cherche à ce que n'apparaissent plus « fichier », « affichage » et «
outils » dans la barre de menus d'un fichier Excel et en plus je souhaite
inhiber le click droit dans cette barre .
Cela est-il possible ?
Par avance merci





Avatar
Gildo
Bonjour et merci,

Ce qui a suscité une petite panique chez moi est réglé
Encore merci



Dans le ThisWorkbook, tu as des événements

"Activate" et "Desactivate" ... tu les utilises selon le cas
pour iniber les comportements que tu désires ou pour
réactiver ces comportements.

Pour remettre à neuf la barre des menus telle qu'elle était
la commande est :
Application.Application.CommandBars(1).reset



"Gildo" a écrit dans le message de news:

J'ai tout flingué
j'ai utilisé la sub test dans l'auto open de mon fichier ça marche impec
même un peu trop car mes autres fichiers non concernés par cette macro ce
voient formatés de la même façon.
En bref mon excel n'a plus outils ni affichage



'---------------------------
Sub test()
On Error Resume Next
Application.CommandBars(1).Controls("Outils").Delete
Application.CommandBars(1).Controls("Affichage").Delete
Application.CommandBars("Toolbar List").Enabled = False
End Sub
'---------------------------

As-tu oublié le double-clic dans l'espace des barres d''outils ?

Pour les versions Excel 2002 et 2003, il y a ceci qui fait le travail :
'-----------------------------
Sub Test_Excel_2002_2003()
Application.CommandBars("Toolbar List").Enabled = False
Application.CommandBars.DisableCustomize = True
End Sub
'-----------------------------

Pour désactiver le double-clic dans la barre d'outils pour les versions plus
anciennes, il y a cette procédure qui fut proposée par Alain Cros.

'******************************************
Dans le module ThisWorkbook

Private Sub Workbook_BeforeClose(Cancel As Boolean)
LeHook
End Sub
Private Sub Workbook_Open()
LeHook True
End Sub

Dans un module ordinaire

Private Declare Function LockWindowUpdate& Lib "user32" ( _
ByVal hwndLock&)
Private Declare Function PostMessage& Lib "user32" _
Alias "PostMessageA" (ByVal hwnd&, ByVal wMsg&, ByVal wParam&, ByVal lParam&)
Private Declare Function FindWindowEx& Lib "user32" _
Alias "FindWindowExA" (ByVal hWnd1&, ByVal hWnd2&, ByVal lpsz1$, ByVal lpsz2$)
Private Declare Function GetWindowLong& Lib "user32" _
Alias "GetWindowLongA" (ByVal hwnd&, ByVal nIndex&)
Private Declare Function GetCurrentThreadId Lib "kernel32" () As Long
Private Declare Function SetWindowsHookEx& Lib "user32" _
Alias "SetWindowsHookExA" (ByVal idHook&, ByVal lpfn&, ByVal hmod&, ByVal dwThreadId&)
Private Declare Function GetWindowText& Lib "user32" _
Alias "GetWindowTextA" (ByVal hwnd&, ByVal lpString$, ByVal cch&)
Private Declare Function UnhookWindowsHookEx& Lib "user32" _
(ByVal hHook&)
Private lgHook&
Sub LeHook(Optional cache As Boolean)
Const GWL_HINSTANCE& = -6
If cache Then
InstallHook GetWindowLong(FindWindowEx(0&, 0&, "XLMAIN", _
Application.Caption), GWL_HINSTANCE)
Else
UnhookWindowsHookEx lgHook
End If
End Sub
Sub InstallHook(lgInst&)
Const WH_CBT& = &H5
#If VBA6 Then
lgHook = SetWindowsHookEx(WH_CBT, AddressOf WinHook, _
lgInst, GetCurrentThreadId)
#Else
lgHook = SetWindowsHookEx(WH_CBT, AddrOf("WinHook"), _
lgInst, GetCurrentThreadId)
#End If
End Sub
Private Function WinHook&(ByVal lMsg&, ByVal wParam&, ByRef lParam&)
Const HCBT_ACTIVATE& = &H5, WM_SYSCOMMAND& = &H112, SC_CLOSE& = &HF060&
Dim MYSTR$
If lMsg = HCBT_ACTIVATE Then
LockWindowUpdate wParam
MYSTR = Space$(100&)
MYSTR = Left$(MYSTR, GetWindowText(wParam, MYSTR, 100&))
If MYSTR = "Personnaliser" Or MYSTR = "Personnalisation" Then
PostMessage wParam, WM_SYSCOMMAND, SC_CLOSE, 0&
Else
LockWindowUpdate False
End If
End If
WinHook = False
End Function
'******************************************



"Gildo" a écrit dans le message de news:

Bonjour,

Je cherche à ce que n'apparaissent plus « fichier », « affichage » et «
outils » dans la barre de menus d'un fichier Excel et en plus je souhaite
inhiber le click droit dans cette barre .
Cela est-il possible ?
Par avance merci