Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default right click menu

how to make it ?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
right click menu excel Jo Vercauteren New Users to Excel 1 May 3rd 05 09:34 PM
Adding a menu item right click menu when clicking on a single. Andoni[_28_] Excel Programming 0 September 2nd 04 10:23 PM
right click menu reset? danped Excel Programming 1 July 14th 04 12:16 PM
Right click menu in my form kvenku Excel Programming 0 April 7th 04 01:18 PM
Adding menu to the mouse right click pop-up menu Jack Excel Programming 1 February 12th 04 05:23 AM


All times are GMT +1. The time now is 01:42 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"