Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 399
Default Add items to VBA-created menu?

I managed to created a custom menu. But I can't find the Add for the new
control to add items under the new menu. Help?

Ed

Sub AddNewMenu()

Dim oCB As CommandBar
Set oCB = Application.CommandBars("Worksheet Menu Bar")
Dim newMenu As CommandBarControl

Set newMenu = oCB.Controls.Add(Type:=10)
newMenu.Caption = "MyMenu"
newMenu.Enabled = True

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 399
Default Add items to VBA-created menu?

Thank you, Bob. That's got me going.

Ed

"Bob Phillips" wrote in message
...
Sub AddNewMenu()

Dim oCB As CommandBar
Set oCB = Application.CommandBars("Worksheet Menu Bar")
Dim newMenu As CommandBarControl

Set newMenu = oCB.Controls.Add(Type:=10)
With newMenu
.Caption = "MyMenu"
.Enabled = True
With .Controls.Add(Type:=msoControlButton)
.Caption = "Button1"
.FaceId = 29
.OnAction = "macro1"
End With
With .Controls.Add(Type:=msoControlButton)
.Caption = "Button2"
.FaceId = 29
.OnAction = "macro2"
End With
End With

End Sub


if you want button icons change the faceid property (John Walkenbach has a
utility to help you at http://j-walk.com/ss/excel/tips/tip67.htm to help
find the values of the FaceIds),

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Ed" wrote in message
...
I managed to created a custom menu. But I can't find the Add for the

new
control to add items under the new menu. Help?

Ed

Sub AddNewMenu()

Dim oCB As CommandBar
Set oCB = Application.CommandBars("Worksheet Menu Bar")
Dim newMenu As CommandBarControl

Set newMenu = oCB.Controls.Add(Type:=10)
newMenu.Caption = "MyMenu"
newMenu.Enabled = True

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
formatting the list items for ComboBox created using Forms Desmond Excel Discussion (Misc queries) 3 May 4th 06 10:04 AM
Add list to newly created menu Anthony Excel Discussion (Misc queries) 4 February 25th 05 01:53 AM
add list to newly created menu Anthony Excel Worksheet Functions 1 February 25th 05 12:57 AM
Menu items added with menu item editor in older versions Michael Hoffmann Excel Discussion (Misc queries) 2 January 7th 05 01:40 PM
Menu item created w/ add-in removed due other add-in Michael Malinsky[_3_] Excel Programming 2 September 16th 04 07:21 PM


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