Customised ContextMenus Not Working in 2007

byhamc

New Member
Joined
Oct 6, 2010
Messages
1
Hi,

I've recently customised some of the contextmenus within Excel (2003), including the Cell and Query menus. This is working fantastically well, giving some better functionality. I've saved the workbook as an Add-In.

I need to use the same code within Excel 2007 as well. The Add-In is there in 2007, and the items appear on the contextmenus OK. However, when I click on any of the new custom items, I get the following error message

'Argument not optional'

I'm not sure where I'm going wrong.

Here's a bit of the code I'm trying to use:

Code:
Sub AddToCellMenu()
    Dim ContextMenu As CommandBar
    Dim MySubMenu As CommandBarControl

    
    Call DeleteFromCellMenu

   
    Set ContextMenu = Application.CommandBars("Cell")

   
    ContextMenu.Controls.Add Type:=msoControlButton, ID:=3, before:=1

    With ContextMenu.Controls.Add(Type:=msoControlButton, before:=2)
    .OnAction = "FormatReport"
    .FaceId = 107
    .Caption = "Format Report"
    .Tag = "My_Cell_Control_Tag"
    End With
End Sub

And the FormatReport Sub:
Code:
Sub FormatReport()
    
    Dim intColumnCount As Integer
    
    'Application.ScreenUpdating = False
    On Error Resume Next
    'Header
    range("A1").Select
    range(Selection, Selection.End(xlToRight)).Select
    Selection.Interior.ColorIndex = 36
End Sub

I've omitted a lot of the code, and there are other subs also, but the same applies to each of them.

Anyone have any suggestions?

Regards
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,214,798
Messages
6,121,636
Members
449,043
Latest member
farhansadik

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top