Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default 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
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default 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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default 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


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default 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



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default 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



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default 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





  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Editor Menu Bar and Toolbar disappears Tonso Excel Discussion (Misc queries) 0 May 19th 10 06:19 PM
menu toolbar disappears and right click wont work in charts Alison Charts and Charting in Excel 0 May 5th 06 02:23 AM
Custom sort in macro disappears backbutton Excel Programming 3 January 31st 06 05:34 PM
addin and main menu disappears Przemek Excel Programming 2 August 4th 05 09:14 AM
Data Analysis Options disappears from Pull Down Menu ch Excel Discussion (Misc queries) 2 June 2nd 05 07:58 AM


All times are GMT +1. The time now is 08:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"