Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
right click menu
how to make it ?
|
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
right click menu
Hi
as starting point some code: Sub Add_Item() Dim New_Entry As Object Set New_Entry = CommandBars("Cell").Controls.Add(Temporary:=True) On Error Resume Next New_Entry.Controls("My message").Delete On Error Goto 0 With New_Entry .Caption = "My message" .OnAction = "Message" End With End Sub Sub Message() MsgBox "Now you code yould start" End Sub Sub Delete_Item() Dim myControl As CommandBarButton For Each myControl In CommandBars("Cell").Controls If myControl.Caption = "My message" Then myControl.Delete End If Next End Sub -- Regards Frank Kabel Frankfurt, Germany "PT SPORT CONTRUCTION CO.,LTD" schrieb im Newsbeitrag ... how to make it ? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
right click menu
Frank's ADd_Item doesn't work for me, if called repeatedly without calling
the Delete_Item in between, it doesn't delete that previously created entry. I changed it to this to make it work Sub Add_Item() Dim New_Entry As Object Set New_Entry = CommandBars("Cell") On Error Resume Next New_Entry.Controls("My message").Delete On Error GoTo 0 Set New_Entry = New_Entry.Controls.Add(Temporary:=True) With New_Entry .Caption = "My message" .OnAction = "Message" End With End Sub Call this code form Worknook_Open event and it will available immediately. An alternative delete routine Sub Delete_Item() Dim myControl As CommandBarButton On Error Resume Next CommandBars("Cell").Controls("My message").Delete On Error Goto 0 End Sub and to save code you could call this from the add routine rather than re-code it. -- HTH RP "Frank Kabel" wrote in message ... Hi as starting point some code: Sub Add_Item() Dim New_Entry As Object Set New_Entry = CommandBars("Cell").Controls.Add(Temporary:=True) On Error Resume Next New_Entry.Controls("My message").Delete On Error Goto 0 With New_Entry .Caption = "My message" .OnAction = "Message" End With End Sub Sub Message() MsgBox "Now you code yould start" End Sub Sub Delete_Item() Dim myControl As CommandBarButton For Each myControl In CommandBars("Cell").Controls If myControl.Caption = "My message" Then myControl.Delete End If Next End Sub -- Regards Frank Kabel Frankfurt, Germany "PT SPORT CONTRUCTION CO.,LTD" schrieb im Newsbeitrag ... how to make it ? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
right click menu excel | New Users to Excel | |||
Adding a menu item right click menu when clicking on a single. | Excel Programming | |||
right click menu reset? | Excel Programming | |||
Right click menu in my form | Excel Programming | |||
Adding menu to the mouse right click pop-up menu | Excel Programming |