Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Newsgroup Archive
Excel Newsgroups
Excel General
Excel buttons change macro file name when run on other computers
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="GS, post: 7425229"] Example code to be placed in a standard module: (I usually name it "m_OpenClose") Option Explicit Sub Auto_Open() CreateMenus End Sub Sub Auto_Close() RemoveMenus End Sub Sub CreateMenus() ' Adds a dropdown menuitem (and submenus) to the Excel Menubar ' between 'Tools' and 'Data'. 'Delete the menuitem if it already exists On Error Resume Next CommandBars(1).Controls("MyUtilities").Delete On Error GoTo 0 'Add the new dropdown menu With CommandBars(1).Controls.Add(Type:=msoControlPopup, _ Before:=CommandBars(1).Controls("Data").Index, _ Temporary:=True) .Caption = "MyUtilities" 'Add submenus With .Controls.Add(msoControlButton) .Caption = "Submenu1" .OnAction = "Procedure1" '.FaceId = 123 '//add icon '.BeginGroup = True '//add separator End With With .Controls.Add(msoControlButton) .Caption = "Submenu2" .OnAction = "Procedure2" '.FaceId = 124 '//add icon '.BeginGroup = True '//add separator End With End With 'CommandBars(1).Controls.Add End Sub Sub RemoveMenus() On Error Resume Next CommandBars(1).Controls("MyUtilities").Delete End Sub Just copy/paste the With...End With blocks to add more submenus. -- Garry Free usenet access at [URL]http://www.eternal-september.org[/URL] Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion [/QUOTE]
Verification
Post reply
Forums
Archive
Newsgroup Archive
Excel Newsgroups
Excel General
Excel buttons change macro file name when run on other computers
Top