ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Adding a separator to a context menu (https://www.excelbanter.com/excel-programming/390147-adding-separator-context-menu.html)

goody

Adding a separator to a context menu
 
I want to add a separator line to isolate the new option I added to the end
of a context menu. I have not been able to find the necessary code. My code
to add the item is taken from a Microsoft example, but I'm not sure it's as
efficient as it could be:

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As
Boolean)
Dim icbc As Object
For Each icbc In Application.CommandBars("cell").Controls
If icbc.Tag = "brccm" Then icbc.Delete
Next icbc
If Not Application.Intersect(Target, Range("RiskItems")) Is Nothing Then
With Application.CommandBars("cell").Controls _
.Add(Type:=msoControlButton, temporary:=True)
.Caption = "Access Risk List"
.OnAction = "ShowList"
.Tag = "brccm"
End With
End If
End Sub


Bob Phillips

Adding a separator to a context menu
 
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As
Boolean)
Dim icbc As Object
For Each icbc In Application.CommandBars("cell").Controls
If icbc.Tag = "brccm" Then icbc.Delete
Next icbc
If Not Application.Intersect(Target, Range("RiskItems")) Is Nothing Then
With Application.CommandBars("cell").Controls _
.Add(Type:=msoControlButton, temporary:=True)
.BeginGroup = True
.Caption = "Access Risk List"
.OnAction = "ShowList"
.Tag = "brccm"
End With
End If
End Sub

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Goody" wrote in message
...
I want to add a separator line to isolate the new option I added to the end
of a context menu. I have not been able to find the necessary code. My
code
to add the item is taken from a Microsoft example, but I'm not sure it's
as
efficient as it could be:

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As
Boolean)
Dim icbc As Object
For Each icbc In Application.CommandBars("cell").Controls
If icbc.Tag = "brccm" Then icbc.Delete
Next icbc
If Not Application.Intersect(Target, Range("RiskItems")) Is Nothing
Then
With Application.CommandBars("cell").Controls _
.Add(Type:=msoControlButton, temporary:=True)
.Caption = "Access Risk List"
.OnAction = "ShowList"
.Tag = "brccm"
End With
End If
End Sub





All times are GMT +1. The time now is 11:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com