Adding a separator to a context menu

G

Guest

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
 
B

Bob Phillips

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top