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

Hi, is it possible to add an item to the right mouse-click menu?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Adding a item to the right click menu?


Hello Silkworm,

Yes it is. Which of the right click menus did you have in mind?

Sincerely,
Leith Ros

--
Leith Ros
-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=49587

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Adding a item to the right click menu?

Thanks for replying. I should've been more clear. What I have in mind
is to write some VBA code, and when a user right click on a cell, have
the right-click menu display the option to run the script.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Adding a item to the right click menu?


Hello Silkworm,

The following macros Add or Remove your custom control from the contex
menu (right click) for Worksheet cells. Once you add your control, i
will remain on the menu until you run the remove macro. You run thi
when you close your program. Otherwise the macro will not be availabl
to other Workbooks eventhough the control still appears on the menu
Change the Caption property to what your control does, and the OnActio
property to the name of the macro to run.
_____________________________


Code
-------------------
Public Sub AddToContextMenu()

Dim C
Dim cmdNew As CommandBarButton

'Don't add the Menu if it exists.
For Each C In Excel.CommandBars("cell").Controls
If C.Caption = "Change Cell and Font Colors" Then
Exit Sub
End If
Next C

Set cmdNew = Excel.CommandBars("cell").Controls.Add
With cmdNew
.Caption = "Change Cell and Font Colors"
.OnAction = "ChangeCellColor"
.BeginGroup = True
End With

End Sub

Public Sub RemoveFromContextMenu()

On Error Resume Next
With CommandBars("cell").Controls("Change Cell and Font Colors")
.BeginGroup = False
.Delete
End With

End Sub

-------------------

_____________________________
Sincerely,
Leith Ros

--
Leith Ros
-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=49587

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
Adding Sub Menu Item to Current Custom Menu Renato Excel Programming 2 December 19th 05 12:48 AM
How to delete item on right click menu? Bobo Excel Discussion (Misc queries) 1 August 28th 05 04:53 PM
Add item to sheet right-click menu? RB Smissaert Excel Programming 5 May 13th 05 04:13 PM
Adding a menu item right click menu when clicking on a single. Andoni[_28_] Excel Programming 0 September 2nd 04 10:23 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 02:38 PM.

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

About Us

"It's about Microsoft Excel"