I have built a DLL using VB 6.0. One of the functions of the DLL is to build a custom menu bar in Excel. I have setup a class with the necessary code to create the menu and it appears to work properly. However, the menu options are not built in the currect version of Excel. Rather, they only appear when I open up Excel from scratch.
My logic in Excel to call my DLL is as follows:
--------------------------------------------------------------------------------Any help would be appreciated. Thanks - JoeVB Code:
Private Sub Workbook_Open() Dim objMenu As Object Set objMenu = CreateObject("adcxxx.clsMyClass") objMenu.Add_Menu_Options End Sub--------------------------------------------------------------------------------My DLL contains the following logic: visual basic code:--------------------------------------------------------------------------------Sub Add_Menu_Options() Dim intHelpMenu As Integer Dim cbrMainMenuBar As CommandBar Dim cstmMyMenu As CommandBarControl Dim menu As CommandBarControl ' Remove the Ellipse menu option if it already exists On Error Resume Next Application.CommandBars("Worksheet Menu Bar").Controls("E&llipse").Delete On Error GoTo 0 ' Set a CommandBar variable to Worksheet menu bar Set cbrMainMenuBar = Application.CommandBars("Worksheet Menu Bar") ' Return the Index number of the Help menu. We can then use this to place a custom menu before. intHelpMenu = cbrMainMenuBar.Controls("Help").Index Set cstmMIMS = cbrMainMenuBar.Controls.Add(Type:=msoControlPopup, Before:=intHelpMenu) cstmMIMS.Caption = "My Menu" With cstmMyMenu.Controls.Add(Type:=msoControlButton) .Caption = "ERP Connect" .OnAction = "ERP_Connect" End With End Sub




Reply With Quote