ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Custom menu disappears (https://www.excelbanter.com/excel-programming/383016-custom-menu-disappears.html)

Fredrik E. Nilsen

Custom menu disappears
 
Ok, probably a stupid question but:

I'm creating a custom menu with buttons to apply custom user defined
charts:

Dim myMenu As Object
Set myMenu = CommandBars("Worksheet menu
bar").Controls.Add(Type:=msoControlPopup)

With myMenu
.Caption = "User defined charts"
. . .
End With

The problem is: this menu disappears when a chart is selected. I can
change it to "Chart menu bar" but then it disappears when no chart is
selected.

What do I have to put there to make the menu visible all the time?

--
Fredrik E. Nilsen

Bob Phillips

Custom menu disappears
 
Add to both Worksheet menu Bar and Chart Menu Bar commandbars.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Fredrik E. Nilsen" wrote in message
...
Ok, probably a stupid question but:

I'm creating a custom menu with buttons to apply custom user defined
charts:

Dim myMenu As Object
Set myMenu = CommandBars("Worksheet menu
bar").Controls.Add(Type:=msoControlPopup)

With myMenu
.Caption = "User defined charts"
. . .
End With

The problem is: this menu disappears when a chart is selected. I can
change it to "Chart menu bar" but then it disappears when no chart is
selected.

What do I have to put there to make the menu visible all the time?

--
Fredrik E. Nilsen




Fredrik E. Nilsen

Custom menu disappears
 
On Mon, 12 Feb 2007 11:28:09 -0000, "Bob Phillips"
wrote:

Add to both Worksheet menu Bar and Chart Menu Bar commandbars.


I'm sorry but I don't know how to do that in the current macro.

--
Fredrik E. Nilsen

Bob Phillips

Custom menu disappears
 
Repeat the code that you have changing Worksheet Menu bar to Chart Menu Bar
in the second instance of that code.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Fredrik E. Nilsen" wrote in message
...
On Mon, 12 Feb 2007 11:28:09 -0000, "Bob Phillips"
wrote:

Add to both Worksheet menu Bar and Chart Menu Bar commandbars.


I'm sorry but I don't know how to do that in the current macro.

--
Fredrik E. Nilsen




Fredrik E. Nilsen

Custom menu disappears
 
On Mon, 12 Feb 2007 13:03:06 -0000, "Bob Phillips"
wrote:

Repeat the code that you have changing Worksheet Menu bar to Chart Menu Bar
in the second instance of that code.


Thanks, I figured out I could do it like that. But it seems strange to
me if there is no method to achieve this in one statement?

--
Fredrik E. Nilsen

Jon Peltier

Custom menu disappears
 
You need to add the menu to two menu bars, so it takes two statements, or a
loop.

Dim myMenu As Object
dim vMenuBars as variant
dim iMenu as integer

vMenuBars = Array("Worksheet Menu Bar", "Chart Menu Bar")
For iMenu = 0 to 1
Set myMenu =
CommandBars(vMenuBar(iMenu)).Controls.Add(Type:=ms oControlPopup)
With myMenu
.Caption = "User defined charts"
' etc.
End With
Next

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Fredrik E. Nilsen" wrote in message
...
On Mon, 12 Feb 2007 13:03:06 -0000, "Bob Phillips"
wrote:

Repeat the code that you have changing Worksheet Menu bar to Chart Menu
Bar
in the second instance of that code.


Thanks, I figured out I could do it like that. But it seems strange to
me if there is no method to achieve this in one statement?

--
Fredrik E. Nilsen




Bob Phillips

Custom menu disappears
 
Why would it? They are separate commandbars applicable to different
circumstances, so it seems reasonable to me that you program both.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Fredrik E. Nilsen" wrote in message
...
On Mon, 12 Feb 2007 13:03:06 -0000, "Bob Phillips"
wrote:

Repeat the code that you have changing Worksheet Menu bar to Chart Menu
Bar
in the second instance of that code.


Thanks, I figured out I could do it like that. But it seems strange to
me if there is no method to achieve this in one statement?

--
Fredrik E. Nilsen




Jon Peltier

Custom menu disappears
 
or...

Dim cBar as commandbar
dim myMenu as CommandBarControl
For Each cBar in Application.Commandbars
If cBar.Type = msoBarTypeMenuBar then
set myMenu = cBar.Controls.Add(Type:=msoControlPopup)
' etc.
End If
Next

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Jon Peltier" wrote in message
...
You need to add the menu to two menu bars, so it takes two statements, or
a loop.

Dim myMenu As Object
dim vMenuBars as variant
dim iMenu as integer

vMenuBars = Array("Worksheet Menu Bar", "Chart Menu Bar")
For iMenu = 0 to 1
Set myMenu =
CommandBars(vMenuBar(iMenu)).Controls.Add(Type:=ms oControlPopup)
With myMenu
.Caption = "User defined charts"
' etc.
End With
Next

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Fredrik E. Nilsen" wrote in message
...
On Mon, 12 Feb 2007 13:03:06 -0000, "Bob Phillips"
wrote:

Repeat the code that you have changing Worksheet Menu bar to Chart Menu
Bar
in the second instance of that code.


Thanks, I figured out I could do it like that. But it seems strange to
me if there is no method to achieve this in one statement?

--
Fredrik E. Nilsen






Fredrik E. Nilsen

Custom menu disappears
 
On Mon, 12 Feb 2007 12:20:35 -0500, "Jon Peltier"
wrote:

or...

Dim cBar as commandbar
dim myMenu as CommandBarControl
For Each cBar in Application.Commandbars
If cBar.Type = msoBarTypeMenuBar then
set myMenu = cBar.Controls.Add(Type:=msoControlPopup)
' etc.
End If
Next


As always: thank you very much for your help!

--
Fredrik E. Nilsen


All times are GMT +1. The time now is 11:36 PM.

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