Could't find a solution? Ask the experts in our
How to Add Popup Menu Item in Excel/Word using VBA
Create Popup Menu (Right Click menu) using VBA
Here is a simple snippet that will add a menu item to the popup menu and assign a macro to it
Public Const APP_SHORTNAME = "VBADUD_POPUP"<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Sub Add_To_Popup_Menu()
Dim ctlNewMenu As CommandBarControl
Dim ctlNewGroup As CommandBarControl
Dim ctlNewItem As CommandBarControl
On Error GoTo Err_Trap
On Error Resume Next
Application.CommandBars("Cell").Controls(APP_SHORTNAME).Delete
On Error GoTo 0
Set ctlNewMenu = Application.CommandBars("Cell").Controls.Add(Type:=msoControlPopup)
ctlNewMenu.Caption = APP_SHORTNAME
'--- Button - Load Raw Data ------------
Set ctlNewItem = ctlNewMenu.Controls.Add(Type:=msoControlButton)
ctlNewItem.Caption = "Process Data"
ctlNewItem.OnAction = "ProcessData"
Err_Trap:
If Err <> 0 Then
Err.Clear
Resume Next
End If
End Sub
The above will create a new Group and add the “Process Data” control to it.
- Login or register to post comments
- Feed: vbadb feed
- Original article
- 414 reads

