Results 1 to 5 of 5
  1. #1
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Illinois
    Posts
    552
    Thanks
    0
    Thanked 1 Time in 1 Post

    Custom menu bar disappears when i select a chart (Excel xp)

    Here is the code i have to add my menu. It adds it fine and runs all the macros but when i select a chart or click on a chart sheet the menu disappears. What causes this behavior and how can i prevent it from doing this. Thanks you very much.

    Sub AddMenus()
    Set mbcontrol = Application.CommandBars("Worksheet Menu Bar").Controls.Add(Type:=msoControlPopup)

    mbcontrol.Caption = "sMacro1"
    With mbcontrol.Controls
    .Add Type:=msoControlButton '1
    .Add Type:=msoControlButton '2 data labels
    .Add Type:=msoControlPopup '3 delete something
    .Add Type:=msoControlPopup '4 find something
    .Add Type:=msoControlPopup '5 format
    .Add Type:=msoControlPopup '6 insert
    .Add Type:=msoControlPopup '7 print
    .Add Type:=msoControlPopup '8 charts
    .Add Type:=msoControlButton '9 shortcuts
    'add another button or popup here
    End With

    With mbcontrol.Controls(1)
    .OnAction = "StartForm"
    .Caption = "Clean Tables"
    .FaceId = 346
    End With

    With mbcontrol.Controls(2)
    .OnAction = "ShowDataLabelForm"
    .Caption = "Data Labels"
    .FaceId = 422
    End With
    ....
    end sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Custom menu bar disappears when i select a chart (Excel xp)

    The reason is that charts have their own version of the menu bar. You'll have to run the same code with "Chart Menu Bar" instead of "Worksheet Menu Bar" too...

  3. #3
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Illinois
    Posts
    552
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Custom menu bar disappears when i select a chart (Excel xp)

    oh, thank you so much.

  4. #4
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Custom menu bar disappears when i select a chart (Excel xp)

    Or create a separate commandbar that holds just your buttons...
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Custom menu bar disappears when i select a chart (Excel xp)

    That's what I do myself for several reasons, of which this is one...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •