Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Excel 2007, Custom Right Click Menu Doesn't Work in Table, Help!

I am trying to customize a right click menu at particular cell location.
However I realize that this method only apply to the cell region, and does
not work on the Table region. For example, I have created a 2x5 table called
"Table1" in sheet1. The following code is suppose to give me a different
right click menu when my right click is within Table region, and back to
default when it is outside the region. However, it doesn't work the way I
wanted. What is the problem? Please help


Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As
Boolean)
If Not Intersect(Target, Sheets(1).Range("Table1")) Is Nothing Then
'Uncomment the following will work if right click outside the table region
'If Intersect(Target, Sheets(1).Range("Table1")) Is Nothing Then
On Error Resume Next
With Application
Dim cControl As CommandBarControl
For Each cControl In .CommandBars("Cell").Controls
cControl.Delete
Next cControl
Dim cBut As CommandBarButton
Dim ii As Integer
For ii = 1 To 3
Set cBut = .CommandBars("Cell").Controls.Add(Temporary:=True)
cBut.Caption = ii
cBut.Style = msoButtonCaption
cBut.OnAction = "MySubStampText"
Next ii
End With
On Error GoTo 0
Else
Application.CommandBars("Cell").Reset
End If
End Sub

Private Sub MySubStampText()
ActiveCell = Application.CommandBars.ActionControl.Caption
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Excel 2007, Custom Right Click Menu Doesn't Work in Table, Help!

Hi cpmame

This is the name of this Popup

Application.CommandBars("List Range Popup")

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"cpmame" wrote in message ...
I am trying to customize a right click menu at particular cell location.
However I realize that this method only apply to the cell region, and does
not work on the Table region. For example, I have created a 2x5 table called
"Table1" in sheet1. The following code is suppose to give me a different
right click menu when my right click is within Table region, and back to
default when it is outside the region. However, it doesn't work the way I
wanted. What is the problem? Please help


Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As
Boolean)
If Not Intersect(Target, Sheets(1).Range("Table1")) Is Nothing Then
'Uncomment the following will work if right click outside the table region
'If Intersect(Target, Sheets(1).Range("Table1")) Is Nothing Then
On Error Resume Next
With Application
Dim cControl As CommandBarControl
For Each cControl In .CommandBars("Cell").Controls
cControl.Delete
Next cControl
Dim cBut As CommandBarButton
Dim ii As Integer
For ii = 1 To 3
Set cBut = .CommandBars("Cell").Controls.Add(Temporary:=True)
cBut.Caption = ii
cBut.Style = msoButtonCaption
cBut.OnAction = "MySubStampText"
Next ii
End With
On Error GoTo 0
Else
Application.CommandBars("Cell").Reset
End If
End Sub

Private Sub MySubStampText()
ActiveCell = Application.CommandBars.ActionControl.Caption
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Excel 2007, Custom Right Click Menu Doesn't Work in Table, Hel

Hi Ron,
Thanks, you have solved my problem.



"Ron de Bruin" wrote:

Hi cpmame

This is the name of this Popup

Application.CommandBars("List Range Popup")

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"cpmame" wrote in message ...
I am trying to customize a right click menu at particular cell location.
However I realize that this method only apply to the cell region, and does
not work on the Table region. For example, I have created a 2x5 table called
"Table1" in sheet1. The following code is suppose to give me a different
right click menu when my right click is within Table region, and back to
default when it is outside the region. However, it doesn't work the way I
wanted. What is the problem? Please help


Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As
Boolean)
If Not Intersect(Target, Sheets(1).Range("Table1")) Is Nothing Then
'Uncomment the following will work if right click outside the table region
'If Intersect(Target, Sheets(1).Range("Table1")) Is Nothing Then
On Error Resume Next
With Application
Dim cControl As CommandBarControl
For Each cControl In .CommandBars("Cell").Controls
cControl.Delete
Next cControl
Dim cBut As CommandBarButton
Dim ii As Integer
For ii = 1 To 3
Set cBut = .CommandBars("Cell").Controls.Add(Temporary:=True)
cBut.Caption = ii
cBut.Style = msoButtonCaption
cBut.OnAction = "MySubStampText"
Next ii
End With
On Error GoTo 0
Else
Application.CommandBars("Cell").Reset
End If
End Sub

Private Sub MySubStampText()
ActiveCell = Application.CommandBars.ActionControl.Caption
End Sub



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel 2007, Custom Right Click Menu Doesn't Work in Table, Hel

Try this code to list out all command bars in your excel setup

Sub commdbrs()
i = 0
For Each cb In CommandBars
i = i + 1
Worksheets("sheet1").Range("A" & i).Value = cb.Name
Next cb
End Sub


"cpmame" wrote:

Hi Ron,
Thanks, you have solved my problem.



"Ron de Bruin" wrote:

Hi cpmame

This is the name of this Popup

Application.CommandBars("List Range Popup")

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"cpmame" wrote in message ...
I am trying to customize a right click menu at particular cell location.
However I realize that this method only apply to the cell region, and does
not work on the Table region. For example, I have created a 2x5 table called
"Table1" in sheet1. The following code is suppose to give me a different
right click menu when my right click is within Table region, and back to
default when it is outside the region. However, it doesn't work the way I
wanted. What is the problem? Please help


Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As
Boolean)
If Not Intersect(Target, Sheets(1).Range("Table1")) Is Nothing Then
'Uncomment the following will work if right click outside the table region
'If Intersect(Target, Sheets(1).Range("Table1")) Is Nothing Then
On Error Resume Next
With Application
Dim cControl As CommandBarControl
For Each cControl In .CommandBars("Cell").Controls
cControl.Delete
Next cControl
Dim cBut As CommandBarButton
Dim ii As Integer
For ii = 1 To 3
Set cBut = .CommandBars("Cell").Controls.Add(Temporary:=True)
cBut.Caption = ii
cBut.Style = msoButtonCaption
cBut.OnAction = "MySubStampText"
Next ii
End With
On Error GoTo 0
Else
Application.CommandBars("Cell").Reset
End If
End Sub

Private Sub MySubStampText()
ActiveCell = Application.CommandBars.ActionControl.Caption
End Sub



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
Lost right-click menu in Excel 2007 Pete K. Setting up and Configuration of Excel 5 September 1st 09 08:58 PM
Custom Context menu (Right click menu) not working in sheet changeevent. Madiya Excel Programming 3 February 11th 08 01:24 PM
Cannot click twice on custom menu in Excel Gerry Excel Programming 0 September 7th 07 01:06 AM
excel 2007 add custom menu ILearner Excel Discussion (Misc queries) 17 April 17th 07 07:18 PM
custom right click menu Father of 7 Excel Programming 1 January 27th 05 01:43 PM


All times are GMT +1. The time now is 01:43 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"