|
-
Jan 10th, 2006, 09:58 AM
#1
Thread Starter
New Member
Building a menu bar for Excel using a VB6 DLL
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:
VB 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
--------------------------------------------------------------------------------Any help would be appreciated. Thanks - Joe
Last edited by RobDog888; Jan 10th, 2006 at 10:17 AM.
Reason: Added [vbcode] tags
-
Jan 10th, 2006, 10:16 AM
#2
Re: Building a menu bar for Excel using a VB6 DLL
Did you create it from a Add-In VB6 project? If so are you using the passed in Application instance?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|