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

Hi NG

Is there someway to add items to the right mouse menu in Excel?
And perhaps even do it dynamically, so that one get some sort of context
sensitive menu?

Regards
Mark


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Context sensitive menu

Hi Mark
try the following procedures (they add/delete an entry to the cell
context menu):


Sub Add_Item()
Dim New_Entry As Object
Set New_Entry = CommandBars("Cell").Controls.Add(Temporary:=True)
With New_Entry
.Caption = "My message"
.OnAction = "Message"
End With
End Sub

Sub Message()
MsgBox "My message is here - put code at this place"
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

Mark wrote:
Hi NG

Is there someway to add items to the right mouse menu in Excel?
And perhaps even do it dynamically, so that one get some sort of
context sensitive menu?

Regards
Mark


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Context sensitive menu

Suggested slight amendment to Frank's code, just as an insurance

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

I would also suggest that you look at John Walkenbach's faceid to see what
built-in faceids youy could select from
http://j-walk.com/ss/excel/tips/tip67.htm

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Frank Kabel" wrote in message
...
Hi Mark
try the following procedures (they add/delete an entry to the cell
context menu):


Sub Add_Item()
Dim New_Entry As Object
Set New_Entry = CommandBars("Cell").Controls.Add(Temporary:=True)
With New_Entry
.Caption = "My message"
.OnAction = "Message"
End With
End Sub

Sub Message()
MsgBox "My message is here - put code at this place"
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

Mark wrote:
Hi NG

Is there someway to add items to the right mouse menu in Excel?
And perhaps even do it dynamically, so that one get some sort of
context sensitive menu?

Regards
Mark




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Context sensitive menu

Hi Bob
good point!

--
Regards
Frank Kabel
Frankfurt, Germany
"Bob Phillips" schrieb im
Newsbeitrag ...
Suggested slight amendment to Frank's code, just as an insurance

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

I would also suggest that you look at John Walkenbach's faceid to see

what
built-in faceids youy could select from
http://j-walk.com/ss/excel/tips/tip67.htm

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Frank Kabel" wrote in message
...
Hi Mark
try the following procedures (they add/delete an entry to the cell
context menu):


Sub Add_Item()
Dim New_Entry As Object
Set New_Entry = CommandBars("Cell").Controls.Add(Temporary:=True)
With New_Entry
.Caption = "My message"
.OnAction = "Message"
End With
End Sub

Sub Message()
MsgBox "My message is here - put code at this place"
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

Mark wrote:
Hi NG

Is there someway to add items to the right mouse menu in Excel?
And perhaps even do it dynamically, so that one get some sort of
context sensitive menu?

Regards
Mark





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Context sensitive menu

Error handling is always nice :-)
Thanks for the link to the faceid application. This will definitetly come
in handy! :-)

/Mark

"Bob Phillips" wrote in message
...
Suggested slight amendment to Frank's code, just as an insurance

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

I would also suggest that you look at John Walkenbach's faceid to see what
built-in faceids youy could select from
http://j-walk.com/ss/excel/tips/tip67.htm

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Frank Kabel" wrote in message
...
Hi Mark
try the following procedures (they add/delete an entry to the cell
context menu):


Sub Add_Item()
Dim New_Entry As Object
Set New_Entry = CommandBars("Cell").Controls.Add(Temporary:=True)
With New_Entry
.Caption = "My message"
.OnAction = "Message"
End With
End Sub

Sub Message()
MsgBox "My message is here - put code at this place"
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

Mark wrote:
Hi NG

Is there someway to add items to the right mouse menu in Excel?
And perhaps even do it dynamically, so that one get some sort of
context sensitive menu?

Regards
Mark








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Context sensitive menu

Thanks alot! works like a charm. :-)


"Frank Kabel" wrote in message
...
Hi Mark
try the following procedures (they add/delete an entry to the cell
context menu):


Sub Add_Item()
Dim New_Entry As Object
Set New_Entry = CommandBars("Cell").Controls.Add(Temporary:=True)
With New_Entry
.Caption = "My message"
.OnAction = "Message"
End With
End Sub

Sub Message()
MsgBox "My message is here - put code at this place"
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

Mark wrote:
Hi NG

Is there someway to add items to the right mouse menu in Excel?
And perhaps even do it dynamically, so that one get some sort of
context sensitive menu?

Regards
Mark




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
Add find and replace to context menu wizardmalcolm Excel Discussion (Misc queries) 0 August 25th 09 12:16 PM
context menu formatting toolbar Robert New Users to Excel 2 July 30th 08 06:20 AM
Add items to context menu Fred Jacobowitz Excel Worksheet Functions 1 April 22nd 06 10:29 PM
Implementing Context Sensitive Help in Excel App using VBA. MGirish Excel Discussion (Misc queries) 0 January 23rd 06 04:13 PM
context sensitive help Malcolm Excel Programming 0 November 19th 03 02:00 PM


All times are GMT +1. The time now is 03:16 AM.

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"