?
Solved

How to Customize Excel menu bar at run time?

Posted on 2002-03-07
2
Medium Priority
?
156 Views
Last Modified: 2010-05-02
Hello all
I need to add items to excel menu bar at runtime
and to load this menu as an Addin.

I prefer to see code that create a new menu item
(like file,edit,tools etc.) and add to it items
and sub menus with connection to event handlers

Thanks
0
Comment
Question by:avi9260
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
nzjonboy earned 280 total points
ID: 6848900
check this out

Sub Auto_Open()
  Dim myBlankPop As CommandBarPopup
  Dim myBlankSubPop As CommandBarPopup
  Dim myBlankBtn As CommandBarButton

  Set myBlankPop = CommandBars("Worksheet Menu Bar").Controls.Add(msoControlPopup, , , 11, True)
 
  With myBlankPop
    .Caption = "Test"
 
    Set myBlankBtn = .Controls.Add(msoControlButton)
 
    With myBlankBtn
      .Style = msoButtonIconAndCaption
      .Caption = "Test Button"
      .FaceId = 480
      .OnAction = "clickBtn"
    End With
   
    Set myBlankBtn = Nothing
   
    Set myBlankSubPop = .Controls.Add(msoControlPopup)
   
    With myBlankSubPop
      .Caption = "Sub Menu"
      Set myBlankBtn = .Controls.Add(msoControlButton)
      With myBlankBtn
        .BeginGroup = True
        .Style = msoButtonIconAndCaption
        .Caption = "Test Button"
        .FaceId = 1845
        .OnAction = "clickSubBtn"
      End With
      Set myBlankBtn = Nothing
    End With
   
    Set myBlankSubPop = Nothing
       
  End With
End Sub

Function clickBtn()
  MsgBox "click"
End Function

Function clickSubBtn()
  MsgBox "click from sub menu"
End Function


hope this helps

nzjonboy
0
 

Author Comment

by:avi9260
ID: 6849932
Thanks a lot
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question