Home |
Search |
Today's Posts |
|
#1
![]() |
|||
|
|||
![]()
When I right-click a cell I get the shortcut menu with cut , copy, paste etc.
I would like to be able to edit this menu and add commands that I frequently use. Hhow is this done? |
#2
![]() |
|||
|
|||
![]()
Look for the ID numbers on this page
http://www.rondebruin.com/menuid.htm This example will add the Paste Special button to the Cell menu after the Paste option. Sub Add_Paste_Special_Button() ' This will add the Paste Special button to the cell menu ' after the Paste option Dim Num As Long Num = Application.CommandBars("Cell"). _ FindControl(ID:=755).Index Application.CommandBars("cell").Controls. _ Add Type:=msoControlButton, ID:=370, befo=Num End Sub Sub Delete_Paste_Special_Button() On Error Resume Next Application.CommandBars("cell").FindControl(ID:=37 0).Delete On Error GoTo 0 End Sub -- Regards Ron de Bruin http://www.rondebruin.nl "LynneN" wrote in message ... When I right-click a cell I get the shortcut menu with cut , copy, paste etc. I would like to be able to edit this menu and add commands that I frequently use. Hhow is this done? |
#3
![]() |
|||
|
|||
![]()
Ron, how is thecode ammended to add more than one item and begin a new group
with the additions. TIA Greg "Ron de Bruin" wrote in message ... Look for the ID numbers on this page http://www.rondebruin.com/menuid.htm This example will add the Paste Special button to the Cell menu after the Paste option. Sub Add_Paste_Special_Button() ' This will add the Paste Special button to the cell menu ' after the Paste option Dim Num As Long Num = Application.CommandBars("Cell"). _ FindControl(ID:=755).Index Application.CommandBars("cell").Controls. _ Add Type:=msoControlButton, ID:=370, befo=Num End Sub Sub Delete_Paste_Special_Button() On Error Resume Next Application.CommandBars("cell").FindControl(ID:=37 0).Delete On Error GoTo 0 End Sub -- Regards Ron de Bruin http://www.rondebruin.nl "LynneN" wrote in message ... When I right-click a cell I get the shortcut menu with cut , copy, paste etc. I would like to be able to edit this menu and add commands that I frequently use. Hhow is this done? |
#4
![]() |
|||
|
|||
![]()
Greg
Not Ron, but sample code. I add my items when the workbook opens. Sub Workbook_Open() With Application.CommandBars("Cell").Controls.Add(tempo rary:=True) .BeginGroup = True .Caption = "Clear Formats" .OnAction = "MyMacros.xla" & "!ClearFormatting" End With End Sub Note: if going this route you should delete the items in a workbook_beforeclose or in the workbook_open othewrwise you will get multiple instances. Application.CommandBars("Cell").Controls("Clear Formats").Delete Gord Dibben Excel MVP On Fri, 28 Jan 2005 11:09:10 -0800, "GregR" wrote: Ron, how is thecode ammended to add more than one item and begin a new group with the additions. TIA Greg "Ron de Bruin" wrote in message ... Look for the ID numbers on this page http://www.rondebruin.com/menuid.htm This example will add the Paste Special button to the Cell menu after the Paste option. Sub Add_Paste_Special_Button() ' This will add the Paste Special button to the cell menu ' after the Paste option Dim Num As Long Num = Application.CommandBars("Cell"). _ FindControl(ID:=755).Index Application.CommandBars("cell").Controls. _ Add Type:=msoControlButton, ID:=370, befo=Num End Sub Sub Delete_Paste_Special_Button() On Error Resume Next Application.CommandBars("cell").FindControl(ID:=37 0).Delete On Error GoTo 0 End Sub -- Regards Ron de Bruin http://www.rondebruin.nl "LynneN" wrote in message ... When I right-click a cell I get the shortcut menu with cut , copy, paste etc. I would like to be able to edit this menu and add commands that I frequently use. Hhow is this done? |
#5
![]() |
|||
|
|||
![]()
Gord, what if I want to add more than one button? Do I include the code
within the With..........End With Statement or do I write another one? Also, what is the difference between a Control ID and .OnAction language. How do I position the control in a certain spot on the menu? TIA Greg "Gord Dibben" <gorddibbATshawDOTca wrote in message ... Greg Not Ron, but sample code. I add my items when the workbook opens. Sub Workbook_Open() With Application.CommandBars("Cell").Controls.Add(tempo rary:=True) .BeginGroup = True .Caption = "Clear Formats" .OnAction = "MyMacros.xla" & "!ClearFormatting" End With End Sub Note: if going this route you should delete the items in a workbook_beforeclose or in the workbook_open othewrwise you will get multiple instances. Application.CommandBars("Cell").Controls("Clear Formats").Delete Gord Dibben Excel MVP On Fri, 28 Jan 2005 11:09:10 -0800, "GregR" wrote: Ron, how is thecode ammended to add more than one item and begin a new group with the additions. TIA Greg "Ron de Bruin" wrote in message ... Look for the ID numbers on this page http://www.rondebruin.com/menuid.htm This example will add the Paste Special button to the Cell menu after the Paste option. Sub Add_Paste_Special_Button() ' This will add the Paste Special button to the cell menu ' after the Paste option Dim Num As Long Num = Application.CommandBars("Cell"). _ FindControl(ID:=755).Index Application.CommandBars("cell").Controls. _ Add Type:=msoControlButton, ID:=370, befo=Num End Sub Sub Delete_Paste_Special_Button() On Error Resume Next Application.CommandBars("cell").FindControl(ID:=37 0).Delete On Error GoTo 0 End Sub -- Regards Ron de Bruin http://www.rondebruin.nl "LynneN" wrote in message ... When I right-click a cell I get the shortcut menu with cut , copy, paste etc. I would like to be able to edit this menu and add commands that I frequently use. Hhow is this done? |
#6
![]() |
|||
|
|||
![]()
I just add another set of code within the Workbook_Open Sub.
With Application.CommandBars("Cell").Controls.Add(tempo rary:=True) .Caption = "Clear Formats" .OnAction = "MyMacros.xla" & "!Change References" End With I have added two groups of three items each to the bottom of my r-click menu in this manner. I have had no success trying to add more than one item within the With/End With lines, but VBA is not my strong suit. It's more like my birthday suit, which is kinda wrinkly<g There is most likely a way. Others will jump in if you hang around. I think Ron's code with the Control ID is easier to use for exact placement. Let's watch this thread so's we both can learn. Gord On Fri, 28 Jan 2005 16:25:56 -0800, "GregR" wrote: Gord, what if I want to add more than one button? Do I include the code within the With..........End With Statement or do I write another one? Also, what is the difference between a Control ID and .OnAction language. How do I position the control in a certain spot on the menu? TIA Greg "Gord Dibben" <gorddibbATshawDOTca wrote in message .. . Greg Not Ron, but sample code. I add my items when the workbook opens. Sub Workbook_Open() With Application.CommandBars("Cell").Controls.Add(tempo rary:=True) .BeginGroup = True .Caption = "Clear Formats" .OnAction = "MyMacros.xla" & "!ClearFormatting" End With End Sub Note: if going this route you should delete the items in a workbook_beforeclose or in the workbook_open othewrwise you will get multiple instances. Application.CommandBars("Cell").Controls("Clear Formats").Delete Gord Dibben Excel MVP On Fri, 28 Jan 2005 11:09:10 -0800, "GregR" wrote: Ron, how is thecode ammended to add more than one item and begin a new group with the additions. TIA Greg "Ron de Bruin" wrote in message ... Look for the ID numbers on this page http://www.rondebruin.com/menuid.htm This example will add the Paste Special button to the Cell menu after the Paste option. Sub Add_Paste_Special_Button() ' This will add the Paste Special button to the cell menu ' after the Paste option Dim Num As Long Num = Application.CommandBars("Cell"). _ FindControl(ID:=755).Index Application.CommandBars("cell").Controls. _ Add Type:=msoControlButton, ID:=370, befo=Num End Sub Sub Delete_Paste_Special_Button() On Error Resume Next Application.CommandBars("cell").FindControl(ID:=37 0).Delete On Error GoTo 0 End Sub -- Regards Ron de Bruin http://www.rondebruin.nl "LynneN" wrote in message ... When I right-click a cell I get the shortcut menu with cut , copy, paste etc. I would like to be able to edit this menu and add commands that I frequently use. Hhow is this done? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel 2003 FAILS, but Excel 2000 SUCCEEDS ??? | Excel Discussion (Misc queries) | |||
Undoing LINKS in Excel 2000 | New Users to Excel | |||
Excel Files Won't Open From Shortcut | Excel Discussion (Misc queries) | |||
Excel Menu Bar | Excel Worksheet Functions | |||
Customise Right Click Menu | Excel Worksheet Functions |