ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Control not added to "Object/Plot" command bar in Excel 2007 (https://www.excelbanter.com/excel-programming/411008-control-not-added-object-plot-command-bar-excel-2007-a.html)

Gail Hurn

Control not added to "Object/Plot" command bar in Excel 2007
 
I'm trying to add a control to the "Object/Plot" and the "Picture Context
Menu" command bars in Excel 2007. I don't get any errors when I add the
controls, but when I right click on a chart or a picture I don't see the new
controls in the context menu or in the Add-In ribbon. If I add a control to
the "Cell" command bar it works as expected.

My OS is Windows XP, SP2.

I created a very simple test that works in Excel 2003, but does not work in
Excel 2007. I don't get any errors. How do you add controls to these
Context Menus in Excel 2007?

Here is the sample code:

Dim chartCommandBar As CommandBar
Dim pictureCommandBar As CommandBar
Dim cellCommandBar As CommandBar
Dim newChartControl As CommandBarControl
Dim newPictureControl As CommandBarControl
Dim newCellControl As CommandBarControl

Set chartCommandBar = ActiveWorkbook.Application.CommandBars("Object/Plot")
Set pictureCommandBar = ActiveWorkbook.Application.CommandBars("Pictures
Context Menu")
Set cellCommandBar = ActiveWorkbook.Application.CommandBars("Cell")

Set newChartControl =
chartCommandBar.Controls.Add(Office.MsoControlType .msoControlButton,
Temporary:=True)

newChartControl.Caption = "Chart Clickme!"
newChartControl.Tag = "Chart.ClickMe.Menu"
newChartControl.Visible = True

Set newPictureControl =
pictureCommandBar.Controls.Add(Office.MsoControlTy pe.msoControlButton,
Temporary:=True)

newPictureControl.Caption = "Picture Clickme!"
newPictureControl.Tag = "Picture.ClickMe.Menu"
newPictureControl.Visible = True

Set newCellControl =
cellCommandBar.Controls.Add(Office.MsoControlType. msoControlButton,
Temporary:=True)

newCellControl.Caption = "Cell Clickme!"
newCellControl.Tag = "Cell.ClickMe.Menu"
newCellControl.Visible = True




All times are GMT +1. The time now is 01:49 PM.

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