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
 

Some videos you may like

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Watch MrExcel Video

Forum statistics

Threads
1,118,875
Messages
5,574,761
Members
412,617
Latest member
mlharris
Top