Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Adding Sub Menu Item to Current Custom Menu

Something like:

Option Explicit
Sub AddNewMenu()

Dim HelpIndex As Integer
Dim NewMenu As CommandBarPopup

On Error Resume Next
Application.CommandBars(1).Controls("&Michigan154" ).Delete
On Error GoTo 0

' Get Index of Help menu
HelpIndex = CommandBars(1).Controls("Help").Index

' Create the control
Set NewMenu = CommandBars(1) _
.Controls.Add(Type:=msoControlPopup, _
Befo=HelpIndex, temporary:=True)
' Add a caption
NewMenu.Caption = "&Michigan154"
End Sub

Sub Allen()
Dim Item As CommandBarControl
Dim SubItem As CommandBarControl
Set Item = CommandBars(1).Controls("Michigan154") _
.Controls.Add(Type:=msoControlPopup)

With Item
.Caption = "&Allen Park"
Set SubItem = .Controls.Add(Type:=msoControlButton, temporary:=True)
With SubItem
.Caption = "next level"
.OnAction = "AllenPark_154"
End With

Set SubItem = .Controls.Add(Type:=msoControlButton, temporary:=True)
With SubItem
.Caption = "next level later"
.OnAction = "AllenPark_155"
End With
End With

End Sub





Renato wrote:

I currently running the following code to create a Custom Menu:

Sub AddNewMenu()
Dim HelpIndex As Integer
Dim NewMenu As CommandBarPopup

' Get Index of Help menu
HelpIndex = CommandBars(1).Controls("Help").Index

' Create the control
Set NewMenu = CommandBars(1) _
.Controls.Add(Type:=msoControlPopup, _
Befo=HelpIndex, Temporary:=True)
' Add a caption
NewMenu.Caption = "&Michigan154"
End Sub

Sub Allen()
Dim Item As CommandBarControl
Set Item = CommandBars(1).Controls("Michigan154") _
.Controls.Add
Item.Caption = "&Allen Park"
Item.OnAction = "AllenPark_154"
End Sub

How can I add some submenus to this?
Thanks


--

Dave Peterson
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
Excel 2000 Custom Menu Item Larry Bird Excel Discussion (Misc queries) 0 November 8th 05 08:25 PM
Adding a menu item right click menu when clicking on a single. Andoni[_28_] Excel Programming 0 September 2nd 04 10:23 PM
VBA-Make Custom Menu Item Fire d_rodman Excel Programming 3 July 27th 04 03:29 PM
Setting OnAction of custom menu item? Ed[_18_] Excel Programming 12 May 10th 04 02:55 PM
Custom Menu Item specific to a workbook Tommy T Excel Programming 1 January 23rd 04 07:34 PM


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