PC Review


Reply
Thread Tools Rate Thread

How to create submenus on Shortcut menus

 
 
jycpooh@yahoo.com
Guest
Posts: n/a
 
      2nd Oct 2008
Hello,

I have a shortcut right-click menu (developed when I was using Excel
2003) that I have used for a while now. I am now using Excel 2007. I
want to modify the right-click code to include fly-out submenus. I am
not sure how to modify it.

Here is the existing code.

Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As
Boolean)
CommandBars("Cell").Reset
If Intersect(Target, Range("RangePnlL", "RangePnlR")) Is Nothing Then
CommandBars("Cell").Reset
Exit Sub
End If
Call RightClick
End Sub

Sub RightClick()
With CommandBars("Cell")

‘****This group is for air-conditioning equipment
******************
With .Controls.Add(temporary:=True)
.Caption = "A/C Eqpt 3-Phase"
.OnAction = "AC3Phase"
.BeginGroup = True
End With
With .Controls.Add(temporary:=True)
.Caption = "A/C Eqpt 2-Phase"
.OnAction = "AC2Phase"
End With
‘*********************************************************

‘****This group is for Motor equipment ******************
With .Controls.Add(temporary:=True)
.Caption = "Motor 3-Phase"
.OnAction = "Motor3Phase"
.BeginGroup = True
End With
With .Controls.Add(temporary:=True)
.Caption = "Motor 2-Phase"
.OnAction = "Motor2Phase"
End With
With .Controls.Add(temporary:=True)
.Caption = "Motor 1-Phase"
.OnAction = "Motor1Phase"
End With
‘*********************************************************

‘****This group is for miscellaneous loads ******************
With .Controls.Add(temporary:=True)
.Caption = "Misc Loads 2-Phase"
.OnAction = "Misc2Phase"
.BeginGroup = True
End With
With .Controls.Add(temporary:=True)
.Caption = "Misc Loads 1-Phase"
.OnAction = "Misc1Phase"
End With
‘*********************************************************

‘****This group is for transformer loads ******************
With .Controls.Add(temporary:=True)
.Caption = "Xfmr 3-Phase"
.OnAction = "Xfmr3Phase"
.BeginGroup = True
End With
With .Controls.Add(temporary:=True)
.Caption = "Xfmr 2-Phase"
.OnAction = "Xfmr2Phase"
End With
‘*********************************************************

End With
End Sub

Here is what I would like to have:
On mouse right click, I would like to see 4 menu items, that is
Air-Conditioning Equipment
Motor
Misc Equipment
Transformer

If I select Motor, it would expand to give me 3 submenus, namely,
Motor 3-phase, Motor 2-phase and Motor 1-phase. Similarly for Air-
Conditioning Eqpt, Misc Equipment and Transformer.

How do I modify the above code to get the submenus?

Thanks
Jim Chee
Houston, TX

 
Reply With Quote
 
 
 
 
Jim Cone
Guest
Posts: n/a
 
      2nd Oct 2008
For each group button, add a popup control to the menu...
Set cmdEquip = .Controls.Add(msoControlPopup)
Then add the menu items to the popup...
Set cmdItem = cmdEquip.Controls.Add(msoControlButton)

Repeat as necessary.
--
Jim Cone
Portland, Oregon USA




<(E-Mail Removed)>
wrote in message
Hello,
I have a shortcut right-click menu (developed when I was using Excel
2003) that I have used for a while now. I am now using Excel 2007. I
want to modify the right-click code to include fly-out submenus. I am
not sure how to modify it.
Here is the existing code.

Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As
Boolean)
CommandBars("Cell").Reset
If Intersect(Target, Range("RangePnlL", "RangePnlR")) Is Nothing Then
CommandBars("Cell").Reset
Exit Sub
End If
Call RightClick
End Sub

Sub RightClick()
With CommandBars("Cell")

‘****This group is for air-conditioning equipment
******************
With .Controls.Add(temporary:=True)
.Caption = "A/C Eqpt 3-Phase"
.OnAction = "AC3Phase"
.BeginGroup = True
End With
With .Controls.Add(temporary:=True)
.Caption = "A/C Eqpt 2-Phase"
.OnAction = "AC2Phase"
End With
‘*****************
-snip-
End Sub

Here is what I would like to have:
On mouse right click, I would like to see 4 menu items, that is
Air-Conditioning Equipment
Motor
Misc Equipment
Transformer

If I select Motor, it would expand to give me 3 submenus, namely,
Motor 3-phase, Motor 2-phase and Motor 1-phase. Similarly for Air-
Conditioning Eqpt, Misc Equipment and Transformer.
How do I modify the above code to get the submenus?
Thanks
Jim Chee
Houston, TX

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Submenus on Shortcut Menus ZipCurs Microsoft Excel Programming 2 4th Mar 2008 09:12 PM
You CAN create shortcut menus with Access 2007 UpRider Microsoft Access 2 15th Oct 2007 03:13 PM
Drop-down & Start menus - no automatic popup of submenus =?Utf-8?B?ZGhmcm4=?= Windows XP Help 0 29th Aug 2007 03:40 AM
creating dynamic menus with submenus from sql paulakeijzers Microsoft ASP .NET 1 8th Nov 2005 10:18 AM
Color of Menus and subMenus Soniy Microsoft Excel Programming 1 16th Sep 2003 09:47 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:29 PM.