|
-
Feb 11th, 2004, 11:21 PM
#1
Thread Starter
Lively Member
Excel VBA Disabling Right Click Menus
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.
-
Feb 13th, 2004, 08:57 PM
#2
Fanatic Member
This should disable the popup on the status bar:
VB Code:
Application.CommandBars("AutoCalculate").Enabled = False
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.
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
-
Feb 14th, 2004, 12:00 PM
#3
Thread Starter
Lively Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|