-----Message d'origine-----
Sub DésactiveMenusContextuels()
Dim menu As CommandBar
For Each menu In Application.CommandBars
If menu.Type = msoBarTypePopup Then menu.Enabled =
False
Next menu
Application.CommandBars("Toolbar List").Enabled = False
End Sub
AV
Merci pour la solution plus moderne concernant la
désactivation des menus contextuels, mais en double
.
-----Message d'origine-----
Sub DésactiveMenusContextuels()
Dim menu As CommandBar
For Each menu In Application.CommandBars
If menu.Type = msoBarTypePopup Then menu.Enabled =
False
Next menu
Application.CommandBars("Toolbar List").Enabled = False
End Sub
AV
Merci pour la solution plus moderne concernant la
désactivation des menus contextuels, mais en double
.
-----Message d'origine-----
Sub DésactiveMenusContextuels()
Dim menu As CommandBar
For Each menu In Application.CommandBars
If menu.Type = msoBarTypePopup Then menu.Enabled =
False
Next menu
Application.CommandBars("Toolbar List").Enabled = False
End Sub
AV
Merci pour la solution plus moderne concernant la
désactivation des menus contextuels, mais en double
.
-----Message d'origine-----
Sub DésactiveMenusContextuels()
Dim menu As CommandBar
For Each menu In Application.CommandBars
If menu.Type = msoBarTypePopup Then menu.Enabled False
Next menu
Application.CommandBars("Toolbar List").Enabled = False
End Sub
AV
Merci pour la solution plus moderne concernant la
désactivation des menus contextuels, mais en double
.
-----Message d'origine-----
Sub DésactiveMenusContextuels()
Dim menu As CommandBar
For Each menu In Application.CommandBars
If menu.Type = msoBarTypePopup Then menu.Enabled False
Next menu
Application.CommandBars("Toolbar List").Enabled = False
End Sub
AV
Merci pour la solution plus moderne concernant la
désactivation des menus contextuels, mais en double
.
-----Message d'origine-----
Sub DésactiveMenusContextuels()
Dim menu As CommandBar
For Each menu In Application.CommandBars
If menu.Type = msoBarTypePopup Then menu.Enabled False
Next menu
Application.CommandBars("Toolbar List").Enabled = False
End Sub
AV
Merci pour la solution plus moderne concernant la
désactivation des menus contextuels, mais en double
.
Bonjour.
Tu peux essayer comme ça.
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
Alain CROS.
"Marcel de Rennes" a écrit dans le message de news: 044d01c3ce1d$2843a0c0$
Je crée à partir d'Excel des programmes utlisateurs
entièrement verouillés en utilisant des barres d'outils
personnalisées que j'attache à mon fichier. Les barres
par défaut d'Excel sont masquées et les touches ou
combinaisons de touches qui ouvrent les boîtes de
dialogue intégrées désactivées. Je désactive également
les menus contextuels par une formule empruntée à Excel
95 à savoir : Application.ShortcutMenus
(xlToolbar).enabled = false. Je n'ai pas trouvé de
correspondance dans Excel 2000. Cette formule bien que
obsolète marche bien sauf pour la boîte de
dialogue "Personnaliser" d'Excel qui s'ouvre quand même
si on effectue un double clic dans l'entête d'Excel qui
contient les barres d'outils que j'ai créées. Cette
ouverture permet de créer éventuellement une barre
d'outils en ajoutant toute sorte de boutons, ce que je ne
veux pas dans mon programme.
J'aimerai résoudre ce problème et améliorer ma formule
pour désactiver les menus contextuels.
Merci aux grands spécialistes...
Bonjour.
Tu peux essayer comme ça.
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
Alain CROS.
"Marcel de Rennes" <anonymous@discussions.microsoft.com> a écrit dans le message de news: 044d01c3ce1d$2843a0c0$a001280a@phx.gbl...
Je crée à partir d'Excel des programmes utlisateurs
entièrement verouillés en utilisant des barres d'outils
personnalisées que j'attache à mon fichier. Les barres
par défaut d'Excel sont masquées et les touches ou
combinaisons de touches qui ouvrent les boîtes de
dialogue intégrées désactivées. Je désactive également
les menus contextuels par une formule empruntée à Excel
95 à savoir : Application.ShortcutMenus
(xlToolbar).enabled = false. Je n'ai pas trouvé de
correspondance dans Excel 2000. Cette formule bien que
obsolète marche bien sauf pour la boîte de
dialogue "Personnaliser" d'Excel qui s'ouvre quand même
si on effectue un double clic dans l'entête d'Excel qui
contient les barres d'outils que j'ai créées. Cette
ouverture permet de créer éventuellement une barre
d'outils en ajoutant toute sorte de boutons, ce que je ne
veux pas dans mon programme.
J'aimerai résoudre ce problème et améliorer ma formule
pour désactiver les menus contextuels.
Merci aux grands spécialistes...
Bonjour.
Tu peux essayer comme ça.
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
Alain CROS.
"Marcel de Rennes" a écrit dans le message de news: 044d01c3ce1d$2843a0c0$
Je crée à partir d'Excel des programmes utlisateurs
entièrement verouillés en utilisant des barres d'outils
personnalisées que j'attache à mon fichier. Les barres
par défaut d'Excel sont masquées et les touches ou
combinaisons de touches qui ouvrent les boîtes de
dialogue intégrées désactivées. Je désactive également
les menus contextuels par une formule empruntée à Excel
95 à savoir : Application.ShortcutMenus
(xlToolbar).enabled = false. Je n'ai pas trouvé de
correspondance dans Excel 2000. Cette formule bien que
obsolète marche bien sauf pour la boîte de
dialogue "Personnaliser" d'Excel qui s'ouvre quand même
si on effectue un double clic dans l'entête d'Excel qui
contient les barres d'outils que j'ai créées. Cette
ouverture permet de créer éventuellement une barre
d'outils en ajoutant toute sorte de boutons, ce que je ne
veux pas dans mon programme.
J'aimerai résoudre ce problème et améliorer ma formule
pour désactiver les menus contextuels.
Merci aux grands spécialistes...
Bonsoir Alain,
Enfin un truc qui fonctionne.. Facile à comprendre comme le dit JPS... ce n'est pas trop tôt !!
;-)
Merci.
Salutations!
"Alain CROS" a écrit dans le message de news:u5e%
Bonjour.
Tu peux essayer comme ça.
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
Alain CROS.
"Marcel de Rennes" a écrit dans le message de news:
044d01c3ce1d$2843a0c0$
Je crée à partir d'Excel des programmes utlisateurs
entièrement verouillés en utilisant des barres d'outils
personnalisées que j'attache à mon fichier. Les barres
par défaut d'Excel sont masquées et les touches ou
combinaisons de touches qui ouvrent les boîtes de
dialogue intégrées désactivées. Je désactive également
les menus contextuels par une formule empruntée à Excel
95 à savoir : Application.ShortcutMenus
(xlToolbar).enabled = false. Je n'ai pas trouvé de
correspondance dans Excel 2000. Cette formule bien que
obsolète marche bien sauf pour la boîte de
dialogue "Personnaliser" d'Excel qui s'ouvre quand même
si on effectue un double clic dans l'entête d'Excel qui
contient les barres d'outils que j'ai créées. Cette
ouverture permet de créer éventuellement une barre
d'outils en ajoutant toute sorte de boutons, ce que je ne
veux pas dans mon programme.
J'aimerai résoudre ce problème et améliorer ma formule
pour désactiver les menus contextuels.
Merci aux grands spécialistes...
Bonsoir Alain,
Enfin un truc qui fonctionne.. Facile à comprendre comme le dit JPS... ce n'est pas trop tôt !!
;-)
Merci.
Salutations!
"Alain CROS" <Personne@ICI> a écrit dans le message de news:u5e%23CMlzDHA.536@tk2msftngp13.phx.gbl...
Bonjour.
Tu peux essayer comme ça.
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
Alain CROS.
"Marcel de Rennes" <anonymous@discussions.microsoft.com> a écrit dans le message de news:
044d01c3ce1d$2843a0c0$a001280a@phx.gbl...
Je crée à partir d'Excel des programmes utlisateurs
entièrement verouillés en utilisant des barres d'outils
personnalisées que j'attache à mon fichier. Les barres
par défaut d'Excel sont masquées et les touches ou
combinaisons de touches qui ouvrent les boîtes de
dialogue intégrées désactivées. Je désactive également
les menus contextuels par une formule empruntée à Excel
95 à savoir : Application.ShortcutMenus
(xlToolbar).enabled = false. Je n'ai pas trouvé de
correspondance dans Excel 2000. Cette formule bien que
obsolète marche bien sauf pour la boîte de
dialogue "Personnaliser" d'Excel qui s'ouvre quand même
si on effectue un double clic dans l'entête d'Excel qui
contient les barres d'outils que j'ai créées. Cette
ouverture permet de créer éventuellement une barre
d'outils en ajoutant toute sorte de boutons, ce que je ne
veux pas dans mon programme.
J'aimerai résoudre ce problème et améliorer ma formule
pour désactiver les menus contextuels.
Merci aux grands spécialistes...
Bonsoir Alain,
Enfin un truc qui fonctionne.. Facile à comprendre comme le dit JPS... ce n'est pas trop tôt !!
;-)
Merci.
Salutations!
"Alain CROS" a écrit dans le message de news:u5e%
Bonjour.
Tu peux essayer comme ça.
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
Alain CROS.
"Marcel de Rennes" a écrit dans le message de news:
044d01c3ce1d$2843a0c0$
Je crée à partir d'Excel des programmes utlisateurs
entièrement verouillés en utilisant des barres d'outils
personnalisées que j'attache à mon fichier. Les barres
par défaut d'Excel sont masquées et les touches ou
combinaisons de touches qui ouvrent les boîtes de
dialogue intégrées désactivées. Je désactive également
les menus contextuels par une formule empruntée à Excel
95 à savoir : Application.ShortcutMenus
(xlToolbar).enabled = false. Je n'ai pas trouvé de
correspondance dans Excel 2000. Cette formule bien que
obsolète marche bien sauf pour la boîte de
dialogue "Personnaliser" d'Excel qui s'ouvre quand même
si on effectue un double clic dans l'entête d'Excel qui
contient les barres d'outils que j'ai créées. Cette
ouverture permet de créer éventuellement une barre
d'outils en ajoutant toute sorte de boutons, ce que je ne
veux pas dans mon programme.
J'aimerai résoudre ce problème et améliorer ma formule
pour désactiver les menus contextuels.
Merci aux grands spécialistes...
Bonsoir Alain,
Enfin un truc qui fonctionne.. Facile à comprendre comme le dit JPS... ce n'est pas trop tôt !!
;-)
Merci.
Salutations!
"Alain CROS" a écrit dans le message de news:u5e%
Bonjour.
Tu peux essayer comme ça.
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
Alain CROS.
"Marcel de Rennes" a écrit dans le message de news:
044d01c3ce1d$2843a0c0$
Je crée à partir d'Excel des programmes utlisateurs
entièrement verouillés en utilisant des barres d'outils
personnalisées que j'attache à mon fichier. Les barres
par défaut d'Excel sont masquées et les touches ou
combinaisons de touches qui ouvrent les boîtes de
dialogue intégrées désactivées. Je désactive également
les menus contextuels par une formule empruntée à Excel
95 à savoir : Application.ShortcutMenus
(xlToolbar).enabled = false. Je n'ai pas trouvé de
correspondance dans Excel 2000. Cette formule bien que
obsolète marche bien sauf pour la boîte de
dialogue "Personnaliser" d'Excel qui s'ouvre quand même
si on effectue un double clic dans l'entête d'Excel qui
contient les barres d'outils que j'ai créées. Cette
ouverture permet de créer éventuellement une barre
d'outils en ajoutant toute sorte de boutons, ce que je ne
veux pas dans mon programme.
J'aimerai résoudre ce problème et améliorer ma formule
pour désactiver les menus contextuels.
Merci aux grands spécialistes...
Bonsoir Alain,
Enfin un truc qui fonctionne.. Facile à comprendre comme le dit JPS... ce n'est pas trop tôt !!
;-)
Merci.
Salutations!
"Alain CROS" <Personne@ICI> a écrit dans le message de news:u5e%23CMlzDHA.536@tk2msftngp13.phx.gbl...
Bonjour.
Tu peux essayer comme ça.
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
Alain CROS.
"Marcel de Rennes" <anonymous@discussions.microsoft.com> a écrit dans le message de news:
044d01c3ce1d$2843a0c0$a001280a@phx.gbl...
Je crée à partir d'Excel des programmes utlisateurs
entièrement verouillés en utilisant des barres d'outils
personnalisées que j'attache à mon fichier. Les barres
par défaut d'Excel sont masquées et les touches ou
combinaisons de touches qui ouvrent les boîtes de
dialogue intégrées désactivées. Je désactive également
les menus contextuels par une formule empruntée à Excel
95 à savoir : Application.ShortcutMenus
(xlToolbar).enabled = false. Je n'ai pas trouvé de
correspondance dans Excel 2000. Cette formule bien que
obsolète marche bien sauf pour la boîte de
dialogue "Personnaliser" d'Excel qui s'ouvre quand même
si on effectue un double clic dans l'entête d'Excel qui
contient les barres d'outils que j'ai créées. Cette
ouverture permet de créer éventuellement une barre
d'outils en ajoutant toute sorte de boutons, ce que je ne
veux pas dans mon programme.
J'aimerai résoudre ce problème et améliorer ma formule
pour désactiver les menus contextuels.
Merci aux grands spécialistes...
Bonsoir Alain,
Enfin un truc qui fonctionne.. Facile à comprendre comme le dit JPS... ce n'est pas trop tôt !!
;-)
Merci.
Salutations!
"Alain CROS" a écrit dans le message de news:u5e%
Bonjour.
Tu peux essayer comme ça.
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
Alain CROS.
"Marcel de Rennes" a écrit dans le message de news:
044d01c3ce1d$2843a0c0$
Je crée à partir d'Excel des programmes utlisateurs
entièrement verouillés en utilisant des barres d'outils
personnalisées que j'attache à mon fichier. Les barres
par défaut d'Excel sont masquées et les touches ou
combinaisons de touches qui ouvrent les boîtes de
dialogue intégrées désactivées. Je désactive également
les menus contextuels par une formule empruntée à Excel
95 à savoir : Application.ShortcutMenus
(xlToolbar).enabled = false. Je n'ai pas trouvé de
correspondance dans Excel 2000. Cette formule bien que
obsolète marche bien sauf pour la boîte de
dialogue "Personnaliser" d'Excel qui s'ouvre quand même
si on effectue un double clic dans l'entête d'Excel qui
contient les barres d'outils que j'ai créées. Cette
ouverture permet de créer éventuellement une barre
d'outils en ajoutant toute sorte de boutons, ce que je ne
veux pas dans mon programme.
J'aimerai résoudre ce problème et améliorer ma formule
pour désactiver les menus contextuels.
Merci aux grands spécialistes...
Bonsoir JPS,
Cependant, il me reste seulement un petit point d'interrogation...où je n'ai pas trouvé de réponse. Pourquoi après avoir
lancé la procédure Workbook_Open de la fenêtre Éditeur de macro, il y a un tout léger sautillement de la barre de titre de la
fenêtre de l'éditeur de Macro ?
;-)
Salutations!
"sabatier" a écrit dans le message de news:
nous sommes donc au moins deux, denis michel!!!
jps
michdenis wrote:Bonsoir Alain,
Enfin un truc qui fonctionne.. Facile à comprendre comme le dit JPS... ce n'est pas trop tôt !!
;-)
Merci.
Salutations!
"Alain CROS" a écrit dans le message de news:u5e%
Bonjour.
Tu peux essayer comme ça.
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
Alain CROS.
"Marcel de Rennes" a écrit dans le message de news:
044d01c3ce1d$2843a0c0$
Je crée à partir d'Excel des programmes utlisateurs
entièrement verouillés en utilisant des barres d'outils
personnalisées que j'attache à mon fichier. Les barres
par défaut d'Excel sont masquées et les touches ou
combinaisons de touches qui ouvrent les boîtes de
dialogue intégrées désactivées. Je désactive également
les menus contextuels par une formule empruntée à Excel
95 à savoir : Application.ShortcutMenus
(xlToolbar).enabled = false. Je n'ai pas trouvé de
correspondance dans Excel 2000. Cette formule bien que
obsolète marche bien sauf pour la boîte de
dialogue "Personnaliser" d'Excel qui s'ouvre quand même
si on effectue un double clic dans l'entête d'Excel qui
contient les barres d'outils que j'ai créées. Cette
ouverture permet de créer éventuellement une barre
d'outils en ajoutant toute sorte de boutons, ce que je ne
veux pas dans mon programme.
J'aimerai résoudre ce problème et améliorer ma formule
pour désactiver les menus contextuels.
Merci aux grands spécialistes...
Bonsoir JPS,
Cependant, il me reste seulement un petit point d'interrogation...où je n'ai pas trouvé de réponse. Pourquoi après avoir
lancé la procédure Workbook_Open de la fenêtre Éditeur de macro, il y a un tout léger sautillement de la barre de titre de la
fenêtre de l'éditeur de Macro ?
;-)
Salutations!
"sabatier" <jpsabat@wanadoo.fr> a écrit dans le message de news:3FF0B37E.C07F169F@wanadoo.fr...
nous sommes donc au moins deux, denis michel!!!
jps
michdenis wrote:
Bonsoir Alain,
Enfin un truc qui fonctionne.. Facile à comprendre comme le dit JPS... ce n'est pas trop tôt !!
;-)
Merci.
Salutations!
"Alain CROS" <Personne@ICI> a écrit dans le message de news:u5e%23CMlzDHA.536@tk2msftngp13.phx.gbl...
Bonjour.
Tu peux essayer comme ça.
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
Alain CROS.
"Marcel de Rennes" <anonymous@discussions.microsoft.com> a écrit dans le message de news:
044d01c3ce1d$2843a0c0$a001280a@phx.gbl...
Je crée à partir d'Excel des programmes utlisateurs
entièrement verouillés en utilisant des barres d'outils
personnalisées que j'attache à mon fichier. Les barres
par défaut d'Excel sont masquées et les touches ou
combinaisons de touches qui ouvrent les boîtes de
dialogue intégrées désactivées. Je désactive également
les menus contextuels par une formule empruntée à Excel
95 à savoir : Application.ShortcutMenus
(xlToolbar).enabled = false. Je n'ai pas trouvé de
correspondance dans Excel 2000. Cette formule bien que
obsolète marche bien sauf pour la boîte de
dialogue "Personnaliser" d'Excel qui s'ouvre quand même
si on effectue un double clic dans l'entête d'Excel qui
contient les barres d'outils que j'ai créées. Cette
ouverture permet de créer éventuellement une barre
d'outils en ajoutant toute sorte de boutons, ce que je ne
veux pas dans mon programme.
J'aimerai résoudre ce problème et améliorer ma formule
pour désactiver les menus contextuels.
Merci aux grands spécialistes...
Bonsoir JPS,
Cependant, il me reste seulement un petit point d'interrogation...où je n'ai pas trouvé de réponse. Pourquoi après avoir
lancé la procédure Workbook_Open de la fenêtre Éditeur de macro, il y a un tout léger sautillement de la barre de titre de la
fenêtre de l'éditeur de Macro ?
;-)
Salutations!
"sabatier" a écrit dans le message de news:
nous sommes donc au moins deux, denis michel!!!
jps
michdenis wrote:Bonsoir Alain,
Enfin un truc qui fonctionne.. Facile à comprendre comme le dit JPS... ce n'est pas trop tôt !!
;-)
Merci.
Salutations!
"Alain CROS" a écrit dans le message de news:u5e%
Bonjour.
Tu peux essayer comme ça.
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
Alain CROS.
"Marcel de Rennes" a écrit dans le message de news:
044d01c3ce1d$2843a0c0$
Je crée à partir d'Excel des programmes utlisateurs
entièrement verouillés en utilisant des barres d'outils
personnalisées que j'attache à mon fichier. Les barres
par défaut d'Excel sont masquées et les touches ou
combinaisons de touches qui ouvrent les boîtes de
dialogue intégrées désactivées. Je désactive également
les menus contextuels par une formule empruntée à Excel
95 à savoir : Application.ShortcutMenus
(xlToolbar).enabled = false. Je n'ai pas trouvé de
correspondance dans Excel 2000. Cette formule bien que
obsolète marche bien sauf pour la boîte de
dialogue "Personnaliser" d'Excel qui s'ouvre quand même
si on effectue un double clic dans l'entête d'Excel qui
contient les barres d'outils que j'ai créées. Cette
ouverture permet de créer éventuellement une barre
d'outils en ajoutant toute sorte de boutons, ce que je ne
veux pas dans mon programme.
J'aimerai résoudre ce problème et améliorer ma formule
pour désactiver les menus contextuels.
Merci aux grands spécialistes...