View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.newusers
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Editing menus in Excel 2007 beta 2

Hi Diggerdeep

Same as in older versions with VBA code

This example will add 3 controls to the Cell menu that run your own macro's.

Change this two lines :

onaction_names = Array("macro1", "macro2", "macro3")
caption_names = Array("caption 1", "caption 2", "caption 3")


Sub Add_Controls()
Dim i As Long
Dim onaction_names As Variant
Dim caption_names As Variant
onaction_names = Array("macro1", "macro2", "macro3")
caption_names = Array("caption 1", "caption 2", "caption 3")
With Application.CommandBars("Cell")
For i = LBound(onaction_names) To UBound(onaction_names)
With .Controls.Add(Type:=msoControlButton)
.OnAction = ThisWorkbook.Name & "!" & onaction_names(i)
.Caption = caption_names(i)
End With
Next i
End With
End Sub

Sub Delete_Controls()
Dim i As Long
Dim caption_names As Variant
caption_names = Array("caption 1", "caption 2", "caption 3")
With Application.CommandBars("Cell")
For i = LBound(caption_names) To UBound(caption_names)
On Error Resume Next
.Controls(caption_names(i)).Delete
On Error GoTo 0
Next i
End With
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Diggerdeep" wrote in message ...
How do I edit the "right click menu" in Excel 2007 Beta 2?