Control not added to "Object/Plot" command bar in Excel 2007

G

Gail Hurn

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.MsoControlType.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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top