LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default Adding a Custom menu / sub menu

Sub CreateMenuItem()
Dim ToolsMenu As CommandBarPopup
Dim NewMenuItem As CommandBarButton

Call DeleteMenuItem

Set ToolsMenu = CommandBars(1).FindControl(ID:=30007)
If ToolsMenu Is Nothing Then
MsgBox "Cannot add Supersum item to Tools menu."
Exit Sub
Else
Set NewMenuItem = ToolsMenu.Controls.Add _
(Type:=msoControlButton)
With NewMenuItem
.Caption = "Supersum"
.OnAction = "loadsum"
End With
End If

End Sub

Sub DeleteMenuItem()
On Error Resume Next
CommandBars(1).FindControl(ID:=30007). _
Controls("Supersum").Delete
End Sub

Sub loadsum()
updater.Show (0)
End Sub


-----

Thats what I have, and it's pretty much copied and pasted 3 times with the
odd word changed so that the other userforms i've created work as well. The
other userforms are calls Manginfo and Prodmon.

As I make more Userforms for people to use the tools menu is getting full of
stuff, so I could do with making a submenu in the tools to show these three
to make it less crowded, and easier for people to spot the extra things i've
done.

To my eternal shame, i've found the answer on this forum, but since I don't
really understand it i've been unable to modify the code to get it to work.

Sub Allen()
Dim Item As CommandBarControl
Set Item = CommandBars(1).Controls("Michigan154") _
.Controls.Add
With Item
.Caption = "&Allen Park"
.OnAction = "AllenPark_154"
With .Controls.Add(Type:=msoControlPopup)
.Caption = "SubMenu"
With .Controls.Add(Type:=msoControlButton)
.Caption = "Sub Item 1"
.OnAction = "myMacro1"
End With
With .Controls.Add(Type:=msoControlButton)
.Caption = "Sub Item 2"
.OnAction = "myMacro2"
End With
End With
End With
End Sub


Is the shortest of the ones I found, and it looks easy enough to add new
subitems with macros as and when needed, but like I said, I couldn't figure
out what I need to change to make it work...

It errored on the set item line, so I changed the controls to tools, and it
got as far as with .controls.add(type:=msocontrolbutton) line and errored
again, and I couldn't figure out how to sort it.
 
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
Adding Sub Menu Item to Current Custom Menu Renato Excel Programming 2 December 19th 05 12:48 AM
Adding a menu item right click menu when clicking on a single. Andoni[_28_] Excel Programming 0 September 2nd 04 10:23 PM
Adding a check mark to the custom made toolbar/menu continue...... aiyer[_59_] Excel Programming 0 September 2nd 04 12:52 AM
Custom Menu return to Excel Menu upon Closing VetcalcReport Excel Programming 2 August 2nd 04 02:59 PM
Adding and Removing Custom Menu Items for one file... Jon Kane Excel Programming 2 September 17th 03 07:23 PM


All times are GMT +1. The time now is 06:33 PM.

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"