ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Adding menu items (https://www.excelbanter.com/excel-programming/321120-adding-menu-items.html)

Claud Balls

Adding menu items
 
I've tried a number of different examples with no luck, so I tried
cutting the examples down to the minimum amount of code needed to add an
item to the menu bar. This is what I came up with:

Sub new_menu()
Dim cbmDemoMenu As CommandBarPopup

On Error Resume Next
Application.CommandBars("Menu Bar") _
.Controls("DEMO").Delete
Set cbmDemoMenu = Application.CommandBars("Menu Bar") _
.Controls.Add(msoControlPopup, "DEMO", , 3, True)
End Sub

I had no luck. I've searched the board, and microsoft's site. Both had
great examples, but ended in invalid procedure calls.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Dave Peterson[_5_]

Adding menu items
 
Is "Menu Bar" your own customized toolbar?

If no, then maybe:

Option Explicit

Sub new_menu()
Dim cbmDemoMenu As CommandBarPopup
On Error Resume Next
Application.CommandBars("Worksheet Menu Bar") _
.Controls("DEMO").Delete
On Error GoTo 0
Set cbmDemoMenu = Application.CommandBars("worksheet Menu Bar") _
.Controls.Add(Type:=msoControlPopup, temporary:=True)
cbmDemoMenu.Caption = "DEMO"
End Sub

Claud Balls wrote:

I've tried a number of different examples with no luck, so I tried
cutting the examples down to the minimum amount of code needed to add an
item to the menu bar. This is what I came up with:

Sub new_menu()
Dim cbmDemoMenu As CommandBarPopup

On Error Resume Next
Application.CommandBars("Menu Bar") _
.Controls("DEMO").Delete
Set cbmDemoMenu = Application.CommandBars("Menu Bar") _
.Controls.Add(msoControlPopup, "DEMO", , 3, True)
End Sub

I had no luck. I've searched the board, and microsoft's site. Both had
great examples, but ended in invalid procedure calls.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


--

Dave Peterson

Claud Balls

Adding menu items
 
Thank you! That worked.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


All times are GMT +1. The time now is 10:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com