Hi.
Thanks for the response. I have already tried that and the message box doesn't appear. If I step through the code the menu gets created so I don't think it's a compatibilty issue.
I can call the function from the Worksheet_SelectionChange event which also creates it. It's the code not running when it's first opened I am struggling with.
Private Sub Workbook_Activate()
' Add the extra menu.
' Note that Workbook_Deactivate removes the menu so that it is only available while the user
' is working on this workbook.
On Error GoTo PROC_ERR
Dim cbrMainMenu As CommandBar
Dim cbpConQuest As CommandBarPopup
Dim cbpWindow As CommandBarPopup
Dim cbpExport As CommandBarPopup
Dim cmdValidate As CommandBarButton
Dim cmdExportIX As CommandBarButton
Dim cmdExportEmail As CommandBarButton
Set cbrMainMenu = Application.CommandBars.Item("Worksheet Menu Bar")
' Remove the menu from the main menu if one already exists.
On Error Resume Next
Call cbrMainMenu.Controls.Item("&EFT Export").Delete
On Error GoTo PROC_ERR
Set cbpWindow = cbrMainMenu.Controls.Item("&Window")
' Create the new menu.
Set cbpConQuest = cbrMainMenu.Controls.Add( _
Type:=msoControlPopup, _
Before:=cbpWindow.Index _
)
Let cbpConQuest.Caption = "&EFT Export"
' Export for sending via email.
Set cmdExportEmail = cbpConQuest.Controls.Add( _
msoControlButton _
)
Let cmdExportEmail.Caption = "Export to QMP"
Let cmdExportEmail.OnAction = "ExportAsCSV_Email"
PROC_EXIT:
Exit Sub
PROC_ERR:
Call MsgError( _
strModule:=mc_strModuleName, _
strProcedure:="Workbook_Activate", _
lngErrNumber:=Err.Number, _
strErrSource:=Err.Source, _
strErrDescription:=Err.Description _
)
GoTo PROC_EXIT
End Sub
Bookmarks