How to create right click commnad bar in excel


Paste code in thisworkbook(vba code) in excel file

For click example file download:-  click here  Right click commandbar file download

Note after code paste file save in macro xlsm format and open again 

Copy below code
__________________________________________________________

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim Contextmenu As CommandBar
Set Contextmenu = Application.CommandBars("Cell")
For Each ctrl In Contextmenu.Controls
If ctrl.Tag = "my_cell_control_tag" Then
ctrl.Delete
End If
Next ctrl
End Sub

Private Sub Workbook_Open()
Dim Contextmenu As CommandBar
Set Contextmenu = Application.CommandBars("Cell")
With Contextmenu.Controls.Add(Type:=msoControlButton, before:=1)
.OnAction = "'" & ThisWorkbook.Name & "'!hello"         ' hello is macro name
.FaceId = 351
.Caption = "hello"
.Tag = "my_cell_control_tag"
End With
End Sub
____________________________________________________________

and Create  a  hello name  macro in  module

Sub hello()
MsgBox "hello nitin world"

End Sub



About Me

author Click here for Connect FB

Click here for Linkedin

Related Post No.

Powered by Blogger.

Contact Form

Name

Email *

Message *

Search This Blog

Recent Posts

Breaking

Popular Posts

Recent Posts

Trending Topic

Breaking

Related Post No.

Pages