ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Custom Menus in Chart Sheets (https://www.excelbanter.com/excel-programming/344915-custom-menus-chart-sheets.html)

Simon Minder

Custom Menus in Chart Sheets
 
Hi all,

I've an Excel workbook with sheets and charts. On the sheets I was able to
include a custom menu, which works fine. However, if I select a chart, the
custom menu disappears. I am aware of the fact that the reason for this
action is the "Worksheet Menu Bar" flag in my code and I need to include the
"Chart Menu Bar" flag.

I tried for quite some time and I couldn't figure out how I can write my
code that the programm knows if I am on a chart or a ordinary sheet and
display the menu.

Does anybody has an idea, how I could include the "Chart Menu Bar" flag into
my code below?

' Set a CommandBar variable to Worksheet menu bar
Set cbMainMenuBar = _
Application.CommandBars("Worksheet Menu Bar")

Thank you very much for your support.

Kind regards,

Simon Minder

Peter T

Custom Menus in Chart Sheets
 
Hi Simon,

Duplicate the custom menu you've put on "Worksheet Menu Bar" on the "Chart
Menu Bar". In other words your custom menu on both bars.

One way to avoid duplicate code might be something like this

For i = 1 to 2
sBar = iif(i = 1, "Worksheet Menu Bar", "Chart Menu Bar")
Set cmdBar = _
Application.CommandBars(sBar)
' custom menu code
Next

Assumes of course your menu goes in a "place" that exists on both bars.

Regards,
Peter T

"Simon Minder" wrote in message
...
Hi all,

I've an Excel workbook with sheets and charts. On the sheets I was able to
include a custom menu, which works fine. However, if I select a chart, the
custom menu disappears. I am aware of the fact that the reason for this
action is the "Worksheet Menu Bar" flag in my code and I need to include

the
"Chart Menu Bar" flag.

I tried for quite some time and I couldn't figure out how I can write my
code that the programm knows if I am on a chart or a ordinary sheet and
display the menu.

Does anybody has an idea, how I could include the "Chart Menu Bar" flag

into
my code below?

' Set a CommandBar variable to Worksheet menu bar
Set cbMainMenuBar = _
Application.CommandBars("Worksheet Menu Bar")

Thank you very much for your support.

Kind regards,

Simon Minder





All times are GMT +1. The time now is 07:29 PM.

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