Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Displaying A custom menu as a popup menu

I've created custom a custom menu with various macros, how can I display this
as a popup (shortcut) menu when a cell is right clicked?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Displaying A custom menu as a popup menu

In the sheet module where you want the right_click menu to appear,
place something like this. You can set a For..Next loop to add as
many buttons as you may need.
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel
As Boolean)
Dim cMain As CommandBarControl, btn As CommandBarControl
For Each cMain In Application.CommandBars("Cell").Controls
If cMain.Caption = "Your Caption Here" Then cMain.Delete
Next
Set cMain = Application.CommandBars("Cell").Controls.Add _
(Type:=msoControlPopup)
cMain.Caption = "Your Caption Here"
Set btn = cMain.Controls.Add
btn.Caption = "Whatver You Want"
btn.OnAction = "SomeMacro"
Set cMain = Nothing
Set btn = Nothing
End Sub

diddy_david wrote:
I've created custom a custom menu with various macros, how can I display this
as a popup (shortcut) menu when a cell is right clicked?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Displaying A custom menu as a popup menu

Thanks but I have already created a toolbar manually, how can this become a
popup menu. In access you change the menu type manually to popup and the
assign the name of the toolbar in a form property, I do't want to create a
new tool bar from scratch.

"JW" wrote:

In the sheet module where you want the right_click menu to appear,
place something like this. You can set a For..Next loop to add as
many buttons as you may need.
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel
As Boolean)
Dim cMain As CommandBarControl, btn As CommandBarControl
For Each cMain In Application.CommandBars("Cell").Controls
If cMain.Caption = "Your Caption Here" Then cMain.Delete
Next
Set cMain = Application.CommandBars("Cell").Controls.Add _
(Type:=msoControlPopup)
cMain.Caption = "Your Caption Here"
Set btn = cMain.Controls.Add
btn.Caption = "Whatver You Want"
btn.OnAction = "SomeMacro"
Set cMain = Nothing
Set btn = Nothing
End Sub

diddy_david wrote:
I've created custom a custom menu with various macros, how can I display this
as a popup (shortcut) menu when a cell is right clicked?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Displaying A custom menu as a popup menu

hi,

I've found this code from excel vba help:

This example adds a new menu item to the shortcut menu for cells
B1:B10.

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, _
Cancel As Boolean)
Dim icbc As Object
For Each icbc In Application.CommandBars("cell").Controls
If icbc.Tag = "brccm" Then icbc.Delete
Next icbc
If Not Application.Intersect(Target, Range("b1:b10")) _
Is Nothing Then
With Application.CommandBars("cell").Controls _
.Add(Type:=msoControlButton, befo=6, _
temporary:=True)
.Caption = "New Context Menu Item"
.OnAction = "MyMacro"
.Tag = "brccm"
End With
End If
End Sub


On Sep 21, 10:34 pm, diddy_david
wrote:
I've created custom a custom menu with various macros, how can I display this
as a popup (shortcut) menu when a cell is right clicked?



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Displaying A custom menu as a popup menu

then maybe you can do it this way

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, _
Cancel As Boolean)

Cancel = True
YourToolBar.show

End Sub

On Sep 21, 10:58 pm, diddy_david
wrote:
Thanks but I have already created a toolbar manually, how can this become a
popup menu. In access you change the menu type manually to popup and the
assign the name of the toolbar in a form property, I do't want to create a
new tool bar from scratch.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 182
Default Displaying A custom menu as a popup menu

Hi,

Worked fine with this code:

'Place code below in the standard module:
Sub popupcmb()
Dim myBar As CommandBar
Dim myBarc As CommandBarButton
Dim myBarcb As CommandBarComboBox
Set myBar = CommandBars.Add(Name:="custom", _
Position:=msoBarPopup, _
Temporary:=False)
Set myBarc = myBar.Controls.Add(Type:=msoControlButton, ID:=1)
With myBarc
.Caption = "Test Bar name"
.OnAction = "Procedure1"
End With
myBar.ShowPopup
myBar.Delete
End Sub

Sub Procedure1()
MsgBox "test"
End Sub


'Place code below in the Worksheet module:
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As
Boolean)
Cancel = True
popupcmb
End Sub

--
Regards,

Halim



"diddy_david" wrote:

I've created custom a custom menu with various macros, how can I display this
as a popup (shortcut) menu when a cell is right clicked?

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
Popup Menu / Shortcut Menu Dale Fye Excel Discussion (Misc queries) 2 October 12th 07 12:57 AM
Custom Floatable Toolbar Popup Menu Pflugs Excel Programming 6 June 14th 07 03:51 PM
Adding Sub Menu Item to Current Custom Menu Renato Excel Programming 2 December 19th 05 12:48 AM
Tooltips won't show up in custom popup menu Brian J. Matuschak Excel Programming 1 November 16th 05 09:13 PM
Custom Menu return to Excel Menu upon Closing VetcalcReport Excel Programming 2 August 2nd 04 02:59 PM


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