Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 132
Default Excel Menus that fold out

Could you give me a snippet that does a dynamic menu with
a sub menu in it similar to the standard on when you go to
File / Print Setup

Thanks

Greg
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Excel Menus that fold out

Hi Greg,

here is an example

Sub PartsMenu()
Dim HelpMenu As CommandBarControl
Dim MainMenu As CommandBarPopup
Dim MenuItem As CommandBarControl
Dim Submenuitem As CommandBarButton

' Deletes menu if it exits
Call DeleteMenu

' Find the help menu
Set HelpMenu = CommandBars(1).FindControl(ID:=30010)


If HelpMenu Is Nothing Then
' Add the menu to the end
Set MainMenu = CommandBars(1).Controls. _
Add(Type:=msoControlPopup, temporary:=True)
Else
' Add menu before help
Set MainMenu = CommandBars(1).Controls. _
Add(Type:=msoControlPopup, befo=HelpMenu.Index, _
temporary:=True)
End If

' Add caption
MainMenu.Caption = "&Parts Utility"

' Searching for parts
Set MenuItem = MainMenu.Controls.Add _
(Type:=msoControlButton)
With MenuItem
.Caption = "&Search Parts..."
.FaceId = 48
.ShortcutText = "Ctrl+Shift+S"
.OnAction = "SetupSearch"
End With

' LO / Remaining printout
Set MenuItem = MainMenu.Controls.Add _
(Type:=msoControlButton)
With MenuItem
.Caption = "&Generate Parts Review..."
.FaceId = 285
.ShortcutText = "Ctrl+Shift+D"
.OnAction = "LORemaining"
End With

' View summary sheet
Set MenuItem = MainMenu.Controls.Add _
(Type:=msoControlPopup)
With MenuItem
.Caption = "Sub menu"
End With

Set Submenuitem = MenuItem.Controls.Add _
(Type:=msoControlButton)
With Submenuitem
.Caption = "&View Summary..."
.FaceId = 592
.OnAction = "Summary"
End With

' Error is here :(
' Print summary sheet
Set Submenuitem = MenuItem.Controls.Add _
(Type:=msoControlButton)
With Submenuitem
.Caption = "Print Summary"
' .Application = 364
.OnAction = "PrintSummary"
End With
End Sub

Sub DeleteMenu()
Application.CommandBars("Worksheet Menu Bar").Controls("Parts
Utility").Delete

End Sub



--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"GJones" wrote in message
...
Could you give me a snippet that does a dynamic menu with
a sub menu in it similar to the standard on when you go to
File / Print Setup

Thanks

Greg



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 195
Default Excel Menus that fold out

Bob Phillips wrote

Sub DeleteMenu()
Application.CommandBars("Worksheet Menu Bar").Controls("Parts
Utility").Delete


To avoid error when first run:

Sub DeleteMenu()
On Error Resume Next 'This will bypass deletion if menu doesn't exist
Application.CommandBars("Worksheet Menu Bar").Controls("Parts
Utility").Delete
End Sub

--
David
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
Sub-menus of main menus for Excel 2007 Eleanor Peppard New Users to Excel 1 March 16th 10 04:12 PM
two-fold problem MRoach Excel Discussion (Misc queries) 3 May 18th 07 07:01 PM
fold change lines Wazooli Charts and Charting in Excel 2 December 14th 04 05:55 PM
Overriding Actions of Excel DropDown Menus and Poup Menus Von Shean Excel Programming 2 February 3rd 04 06:43 AM
A 2 fold macro question. *(I need some MVP help on this one.) J.E. McGimpsey Excel Programming 0 December 10th 03 09:40 PM


All times are GMT +1. The time now is 02:23 AM.

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"