Does anyone know how to disable or modify the right click menu that appears when you right click on a) the scrollbar and b) the Status Bar in Excel.
I tried the Workbook_SheetBeforeRightClick event but it has no effect on these excel components.
Printable View
Does anyone know how to disable or modify the right click menu that appears when you right click on a) the scrollbar and b) the Status Bar in Excel.
I tried the Workbook_SheetBeforeRightClick event but it has no effect on these excel components.
This should disable the popup on the status bar:
As you can see, that applies to the whole application. If you just want it disabled for a workbook you can use that code to toggle it in the Workbook Activate/Deactivate events.VB Code:
Application.CommandBars("AutoCalculate").Enabled = False
For more info on working with CommandBars (like adding controls, etc.) see the Excel VBA help file topic "CommandBar Object".
I don't have any popups on the scrollbars (Excel 2000). There is probably some documentation of all the built-in CommandBars somewhere, but I just use the code below to find the CommandBar name. Kepp in mind that if a letter is underlined, that means there is an amersand before the letter in the actual control caption.
:)VB Code:
Sub FindCommandBar() Dim cb As CommandBar Dim cbc As CommandBarControl Dim strControlCaption As String strControlCaption = "&None" For Each cb In Application.CommandBars For Each cbc In Application.CommandBars(cb.Name).Controls If cbc.Caption = strControlCaption Then Debug.Print cb.Name Exit For End If Next cbc Next cb End Sub
Works like a charm. Thanks.
But I still don't understand why the following code still leaves that menu. Especially when your code makes an explicit reference to a member of the commandbar collection.
Dim bar As CommandBar
For Each bar In Application.CommandBars
bar.Enabled = False
Next