Attribute VB_Name = "modRechtsklik" Option Explicit Sub MenuToevoegenRechtsklik() ' ______________________________________________________________________________ ' | | ' | Wim Gielis | ' | http://www.wimgielis.be | ' | Custom module to add items to the context menu when right clicking a cell | ' | 05/05/07 | ' |______________________________________________________________________________| 'see also: http://www.mvps.org/dmcritchie/excel/ccomment.htm 'see also: http://www.contextures.com/xlcomments03.html 'voorafgaande noot: Validatie gebruiken is een alternatief voor het gebruik van opmerkingen Dim NewItem As CommandBarPopup Dim NewMenuItem As CommandBarButton MenuVerwijderenRechtsklik Set NewItem = CommandBars("Cell").Controls.Add(Type:=msoControlPopup, temporary:=True) With NewItem .Caption = "P&as een kleurtje toe" .BeginGroup = True End With Set NewMenuItem = NewItem.Controls.Add(Type:=msoControlButton) With NewMenuItem .Caption = "Ro&de tekstkleur" .OnAction = "RodeTekstkleur" .FaceId = 2628 End With Set NewMenuItem = NewItem.Controls.Add(Type:=msoControlButton) With NewMenuItem .Caption = "Blau&we celkleur" .OnAction = "BlauweCelkleur" .FaceId = 1381 End With End Sub Sub MenuVerwijderenRechtsklik() On Error Resume Next CommandBars("Cell").Controls("Pas een kleurtje toe").Delete End Sub Private Sub RodeTekstkleur() 'heel simpele voorbeeldprocedure om de werking van de bovenstaande code duidelijk te maken Selection.Font.ColorIndex = 3 End Sub Private Sub BlauweCelkleur() 'heel simpele voorbeeldprocedure om de werking van de bovenstaande code duidelijk te maken Selection.Interior.ColorIndex = 41 End Sub